@fin.cx/mt940 2.0.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.
@@ -0,0 +1,54 @@
1
+ {
2
+ "@git.zone/cli": {
3
+ "schemaVersion": 2,
4
+ "projectType": "npm",
5
+ "module": {
6
+ "githost": "code.foss.global",
7
+ "gitscope": "fin.cx",
8
+ "gitrepo": "mt940",
9
+ "description": "A parser to process and extract statements from MT940 format files, commonly used by banks for electronic account statements.",
10
+ "npmPackagename": "@fin.cx/mt940",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "MT940",
14
+ "file parser",
15
+ "financial statements",
16
+ "banking",
17
+ "finance",
18
+ "TypeScript",
19
+ "electronic account statements",
20
+ "data extraction"
21
+ ]
22
+ },
23
+ "release": {
24
+ "confirmation": "prompt",
25
+ "preflight": {
26
+ "requireCleanTree": true,
27
+ "test": false,
28
+ "build": true
29
+ },
30
+ "targets": {
31
+ "git": {
32
+ "enabled": true,
33
+ "remote": "origin",
34
+ "pushBranch": true,
35
+ "pushTags": true
36
+ },
37
+ "npm": {
38
+ "enabled": true,
39
+ "registries": [
40
+ "https://verdaccio.lossless.digital",
41
+ "https://registry.npmjs.org"
42
+ ],
43
+ "accessLevel": "public",
44
+ "alreadyPublished": "success"
45
+ },
46
+ "docker": {
47
+ "enabled": false,
48
+ "engine": "tsdocker",
49
+ "patterns": []
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
+ */
4
+ export declare const commitinfo: {
5
+ name: string;
6
+ version: string;
7
+ description: string;
8
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
+ */
4
+ export const commitinfo = {
5
+ name: '@fin.cx/mt940',
6
+ version: '2.0.0',
7
+ description: 'A parser to process and extract statements from MT940 format files, commonly used by banks for electronic account statements.'
8
+ };
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxlQUFlO0lBQ3JCLE9BQU8sRUFBRSxPQUFPO0lBQ2hCLFdBQVcsRUFBRSwrSEFBK0g7Q0FDN0ksQ0FBQSJ9
@@ -0,0 +1,5 @@
1
+ import * as plugins from './mt940parser.plugins.js';
2
+ export declare class Mt940Parser {
3
+ parseMt940FileString(fileStringArg: string): Promise<plugins.mt940Js.Statement[]>;
4
+ parseMt940Buffer(fileBufferArg: ArrayBufferLike): Promise<plugins.mt940Js.Statement[]>;
5
+ }
@@ -0,0 +1,22 @@
1
+ import * as plugins from './mt940parser.plugins.js';
2
+ export class Mt940Parser {
3
+ async parseMt940FileString(fileStringArg) {
4
+ const textEncode = new TextEncoder();
5
+ const statements = await this.parseMt940Buffer(textEncode.encode(fileStringArg).buffer);
6
+ return statements;
7
+ }
8
+ async parseMt940Buffer(fileBufferArg) {
9
+ const fileBuffer = fileBufferArg instanceof ArrayBuffer
10
+ ? fileBufferArg
11
+ : new Uint8Array(fileBufferArg).slice().buffer;
12
+ const statements = await plugins.mt940Js.read(fileBuffer);
13
+ // bank afterburner
14
+ for (const statement of statements) {
15
+ if (statement.referenceNumber === 'BUNQ BV' && statement.accountId) {
16
+ statement.accountId = statement.accountId.split(' ')[0];
17
+ }
18
+ }
19
+ return statements;
20
+ }
21
+ }
22
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1l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0,0 +1,2 @@
1
+ import * as mt940Js from 'mt940-js';
2
+ export { mt940Js };
@@ -0,0 +1,3 @@
1
+ import * as mt940Js from 'mt940-js';
2
+ export { mt940Js };
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibXQ5NDBwYXJzZXIucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL210OTQwcGFyc2VyLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxVQUFVLENBQUM7QUFFcEMsT0FBTyxFQUNMLE9BQU8sRUFDUixDQUFDIn0=
package/license ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Task Venture Capital GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@fin.cx/mt940",
3
+ "version": "2.0.0",
4
+ "private": false,
5
+ "description": "A parser to process and extract statements from MT940 format files, commonly used by banks for electronic account statements.",
6
+ "main": "dist_ts/index.js",
7
+ "typings": "dist_ts/index.d.ts",
8
+ "type": "module",
9
+ "author": "Task Venture Capital GmbH",
10
+ "license": "MIT",
11
+ "devDependencies": {
12
+ "@git.zone/tsbuild": "^4.4.2",
13
+ "@git.zone/tsbundle": "^2.10.1",
14
+ "@git.zone/tsrun": "^2.0.5",
15
+ "@git.zone/tstest": "^3.6.6",
16
+ "@types/node": "^26.1.0"
17
+ },
18
+ "browserslist": [
19
+ "last 1 chrome versions"
20
+ ],
21
+ "files": [
22
+ "ts/**/*",
23
+ "ts_web/**/*",
24
+ "dist/**/*",
25
+ "dist_*/**/*",
26
+ "dist_ts/**/*",
27
+ "dist_ts_web/**/*",
28
+ "assets/**/*",
29
+ "cli.js",
30
+ ".smartconfig.json",
31
+ "license",
32
+ "readme.md"
33
+ ],
34
+ "dependencies": {
35
+ "mt940-js": "^1.0.0"
36
+ },
37
+ "keywords": [
38
+ "MT940",
39
+ "file parser",
40
+ "financial statements",
41
+ "banking",
42
+ "finance",
43
+ "TypeScript",
44
+ "electronic account statements",
45
+ "data extraction",
46
+ "custom processing",
47
+ "file handling",
48
+ "error handling"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://code.foss.global/fin.cx/mt940.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://code.foss.global/fin.cx/mt940/issues"
56
+ },
57
+ "homepage": "https://code.foss.global/fin.cx/mt940#readme",
58
+ "scripts": {
59
+ "test": "tstest test/",
60
+ "build": "tsbuild",
61
+ "buildDocs": "(tsdoc)"
62
+ }
63
+ }
File without changes
package/readme.md ADDED
@@ -0,0 +1,139 @@
1
+ # @fin.cx/mt940
2
+
3
+ `@fin.cx/mt940` is a small TypeScript wrapper around `mt940-js` for parsing MT940 electronic bank statement data into structured JavaScript objects. It accepts MT940 content as a string or `ArrayBufferLike`, returns the parsed statement model from `mt940-js`, and includes a BUNQ-specific account id normalization step for statements whose reference number is `BUNQ BV`.
4
+
5
+ ## Issue Reporting and Security
6
+
7
+ For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pnpm add @fin.cx/mt940
13
+ ```
14
+
15
+ ## What It Does
16
+
17
+ - Parses complete MT940 file content from a string with `parseMt940FileString()`.
18
+ - Parses MT940 data from an `ArrayBufferLike` with `parseMt940Buffer()`.
19
+ - Returns the statement, balance, and transaction objects produced by `mt940-js`.
20
+ - Normalizes BUNQ statement account ids by stripping the trailing currency segment from `accountId`.
21
+ - Works with modern ESM TypeScript projects.
22
+
23
+ ## Basic Usage
24
+
25
+ ```typescript
26
+ import { Mt940Parser } from '@fin.cx/mt940';
27
+
28
+ const mt940Content = `:20:STARTUMS
29
+ :25:NL91ABNA0417164300
30
+ :28C:00000
31
+ :60F:C180605EUR0,00
32
+ :61:1806050605D5,00NTRFNONREF//123
33
+ :86:/TRCD/001/NAME/Test transaction
34
+ :62F:C180605EUR5,00
35
+ -`;
36
+
37
+ const parser = new Mt940Parser();
38
+ const statements = await parser.parseMt940FileString(mt940Content);
39
+
40
+ console.log(statements[0].accountId); // NL91ABNA0417164300
41
+ console.log(statements[0].transactions[0].amount); // 5
42
+ ```
43
+
44
+ ## Parsing File Data In Node.js
45
+
46
+ `parseMt940Buffer()` expects an `ArrayBufferLike`. When reading with Node.js, slice the underlying `ArrayBuffer` to the actual byte range of the `Buffer`.
47
+
48
+ ```typescript
49
+ import { readFile } from 'node:fs/promises';
50
+ import { Mt940Parser } from '@fin.cx/mt940';
51
+
52
+ const parser = new Mt940Parser();
53
+ const fileBuffer = await readFile('./statement.mt940');
54
+ const arrayBuffer = fileBuffer.buffer.slice(
55
+ fileBuffer.byteOffset,
56
+ fileBuffer.byteOffset + fileBuffer.byteLength
57
+ );
58
+
59
+ const statements = await parser.parseMt940Buffer(arrayBuffer);
60
+ console.log(statements);
61
+ ```
62
+
63
+ ## Parsing Browser File Uploads
64
+
65
+ Browser `File` objects already expose `arrayBuffer()`, so uploaded MT940 files can be parsed without Node.js APIs.
66
+
67
+ ```typescript
68
+ import { Mt940Parser } from '@fin.cx/mt940';
69
+
70
+ const parser = new Mt940Parser();
71
+
72
+ async function parseUploadedMt940(file: File) {
73
+ const statements = await parser.parseMt940Buffer(await file.arrayBuffer());
74
+ return statements;
75
+ }
76
+ ```
77
+
78
+ ## Returned Data
79
+
80
+ The returned statement objects come from `mt940-js` and include fields such as:
81
+
82
+ - `referenceNumber`
83
+ - `accountId`
84
+ - `number`
85
+ - `openingBalance`
86
+ - `closingBalance`
87
+ - `transactions`
88
+
89
+ Transaction objects include fields such as:
90
+
91
+ - `id`
92
+ - `code`
93
+ - `isCredit`
94
+ - `isExpense`
95
+ - `currency`
96
+ - `description`
97
+ - `amount`
98
+ - `valueDate`
99
+ - `entryDate`
100
+ - `customerReference`
101
+ - `bankReference`
102
+
103
+ ## BUNQ Account Id Normalization
104
+
105
+ Some BUNQ MT940 exports provide an `accountId` with a trailing currency segment, for example `NL91BUNQ1234567890 EUR`. When a parsed statement has `referenceNumber === 'BUNQ BV'`, this module rewrites that `accountId` to `NL91BUNQ1234567890`.
106
+
107
+ ```typescript
108
+ const statements = await parser.parseMt940FileString(bunqMt940Content);
109
+ console.log(statements[0].accountId); // NL91BUNQ1234567890
110
+ ```
111
+
112
+ ## Development
113
+
114
+ ```sh
115
+ pnpm install
116
+ pnpm test
117
+ pnpm run build
118
+ ```
119
+
120
+ ## License and Legal Information
121
+
122
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./license) file.
123
+
124
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
125
+
126
+ ### Trademarks
127
+
128
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
129
+
130
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
131
+
132
+ ### Company Information
133
+
134
+ Task Venture Capital GmbH
135
+ Registered at District Court Bremen HRB 35230 HB, Germany
136
+
137
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
138
+
139
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
+ */
4
+ export const commitinfo = {
5
+ name: '@fin.cx/mt940',
6
+ version: '2.0.0',
7
+ description: 'A parser to process and extract statements from MT940 format files, commonly used by banks for electronic account statements.'
8
+ }
package/ts/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ import * as plugins from './mt940parser.plugins.js';
2
+
3
+ export class Mt940Parser {
4
+ public async parseMt940FileString(fileStringArg: string) {
5
+ const textEncode = new TextEncoder();
6
+ const statements = await this.parseMt940Buffer(textEncode.encode(fileStringArg).buffer);
7
+
8
+ return statements;
9
+ }
10
+
11
+ public async parseMt940Buffer(fileBufferArg: ArrayBufferLike) {
12
+ const fileBuffer = fileBufferArg instanceof ArrayBuffer
13
+ ? fileBufferArg
14
+ : new Uint8Array(fileBufferArg).slice().buffer as ArrayBuffer;
15
+ const statements = await plugins.mt940Js.read(fileBuffer);
16
+
17
+ // bank afterburner
18
+ for (const statement of statements) {
19
+ if (statement.referenceNumber === 'BUNQ BV' && statement.accountId) {
20
+ statement.accountId = statement.accountId.split(' ')[0];
21
+ }
22
+ }
23
+
24
+ return statements;
25
+ }
26
+ }
@@ -0,0 +1,5 @@
1
+ import * as mt940Js from 'mt940-js';
2
+
3
+ export {
4
+ mt940Js
5
+ };