Skip to content

Commit

Permalink
feat(ynab-parsers): add DKB parser (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekeih authored Dec 28, 2023
1 parent 781cacf commit 8a11bd3
Show file tree
Hide file tree
Showing 11 changed files with 1,040 additions and 170 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages/ynap-parsers/src/bank2ynab/banks.json
packages/ynap-parsers/src/**/test-data/**
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/ynap-parsers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envelope-zero/ynap-parsers",
"version": "1.15.49",
"version": "1.16.0",
"description": "Parsers from various formats to YNAB CSV",
"main": "index.js",
"author": "Envelope Zero Team <[email protected]> (https://envelope-zero.org)",
Expand Down Expand Up @@ -37,6 +37,6 @@
"test": "jest",
"test:watch": "jest --watch",
"build": "npx jest && tsc && cp -r ./lib/* . && rm -rf ./lib",
"fetch-bank2ynab": "ynap-bank2ynab-converter -b cf153c196acd809a2e67638df9c8bc157345f567 -o src/bank2ynab/banks.json"
"fetch-bank2ynab": "ynap-bank2ynab-converter --branch develop --output src/bank2ynab/banks.json"
}
}
18 changes: 13 additions & 5 deletions packages/ynap-parsers/src/bank2ynab/bank2ynab.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ParserConfig } from '@envelope-zero/ynap-bank2ynab-converter/parserconfig'
import 'mdn-polyfills/String.prototype.startsWith'
import { ParserFunction, MatcherFunction, ParserModule, YnabRow } from '..'
import { MatcherFunction, ParserFunction, ParserModule, YnabRow } from '..'
import { parse as parseCsv } from '../util/papaparse'
import { readEncodedFile } from '../util/read-encoded-file'
import { parseDate, ynabDate } from './parse-date'
import { ParserConfig } from '@envelope-zero/ynap-bank2ynab-converter/parserconfig'

import banks from './banks.json'

Expand Down Expand Up @@ -133,7 +133,10 @@ export const generateParser = (config: ParserConfig) => {
}

// Get all rows after the header row, filter empty lines, filter lines without a date (pending transactions), then use the first row of that
const row = data.slice(config.headerRows).filter(d => d.length > 1).filter(d => d[columns.Date] != "")[0]
const row = data
.slice(config.headerRows)
.filter(d => d.length > 1)
.filter(d => d[columns.Date] != '')[0]

// Check that the date column is set correctly
try {
Expand Down Expand Up @@ -171,7 +174,7 @@ export const generateParser = (config: ParserConfig) => {
const ynabData = data
.slice(config.headerRows, data.length - config.footerRows) // Filter header and footer rows
.filter(d => d.length > 1) // Filter empty lines
.filter(d => d[columns.Date] != "") // Filter lines without date (pending transactions)
.filter(d => d[columns.Date] != '') // Filter lines without date (pending transactions)
.map(
d =>
({
Expand Down Expand Up @@ -230,7 +233,12 @@ export const generateParser = (config: ParserConfig) => {
} as ParserModule
}

const ignorelist = ['de N26', 'de ING-DiBa', 'ie N26']
const ignorelist = [
'de N26',
'de ING-DiBa',
'ie N26',
'de Deutsche Kreditbank checking new',
]
export const bank2ynab = banks
.filter(b => !ignorelist.includes(`${b.country} ${b.name}`))
.map(bank => generateParser(bank as ParserConfig))
Loading

0 comments on commit 8a11bd3

Please sign in to comment.