feat(core): Added new afterburner logic for specific bank reference
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@fin.cx/mt940parser',
|
||||
version: '1.1.0',
|
||||
description: 'A parser to process and extract statements from MT940 format files, commonly used by banks for electronic account statements.'
|
||||
}
|
26
ts/index.ts
Normal file
26
ts/index.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import * as plugins from './mt940parser.plugins.js';
|
||||
|
||||
export class Mt940Parser {
|
||||
public async parseMt940FileString(fileStringArg: string) {
|
||||
// console.log(fileStringArg);
|
||||
const textEncode = new TextEncoder();
|
||||
const statements = await this.parseMt940Buffer(textEncode.encode(fileStringArg).buffer);
|
||||
|
||||
return statements;
|
||||
}
|
||||
|
||||
public async parseMt940Buffer(fileBufferArg: ArrayBufferLike) {
|
||||
// console.log(fileStringArg);
|
||||
const textEncode = new TextEncoder();
|
||||
const statements = await plugins.mt940Js.read(fileBufferArg);
|
||||
|
||||
// bank afterburner
|
||||
for (const statement of statements) {
|
||||
if (statement.referenceNumber === "BUNQ BV") {
|
||||
statement.accountId = statement.accountId.split(' ')[0];
|
||||
}
|
||||
}
|
||||
|
||||
return statements;
|
||||
}
|
||||
}
|
5
ts/mt940parser.plugins.ts
Normal file
5
ts/mt940parser.plugins.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as mt940Js from 'mt940-js';
|
||||
|
||||
export {
|
||||
mt940Js
|
||||
}
|
Reference in New Issue
Block a user