Skip to content

Commit

Permalink
fix: Trade Republic items (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
morremeyer authored Feb 2, 2024
1 parent d9182ca commit c940d5a
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 93 deletions.
2 changes: 1 addition & 1 deletion 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.17.0",
"version": "1.17.1",
"description": "Parsers from various formats to YNAB CSV",
"main": "index.js",
"author": "Envelope Zero Team <[email protected]> (https://envelope-zero.org)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,69 +1,66 @@
{
"items": [
{
"id": "3af95aed-76a9-4142-9c9b-d4fb2598e013",
"timestamp": "2024-02-04T15:56:33.375+0000",
"title": "Zinsen",
"icon": "logos/timeline_interest_new/v2",
"badge": null,
"subtitle": null,
"amount": { "currency": "EUR", "value": 10, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "3af95aed-76a9-4142-9c9b-d4fb2598e013"
},
"eventType": "INTEREST_PAYOUT_CREATED"
},
{
"id": "e2f5c297-79ab-4118-8a79-8ce7d53a4b41",
"timestamp": "2023-06-11T15:44:14.017+0000",
"title": "Einzahlung",
"icon": "logos/timeline_plus_circle/v2",
"badge": null,
"subtitle": null,
"amount": { "currency": "EUR", "value": 50.0, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "e2f5c297-79ab-4118-8a79-8ce7d53a4b41"
},
"eventType": "PAYMENT_INBOUND_SEPA_DIRECT_DEBIT"
},
{
"id": "5b17cc36-67ec-4e39-9c24-a26f653634d5",
"timestamp": "2017-10-17T08:11:08.217+0000",
"title": "Some Asset",
"icon": "logos/IDENTIFIER/v2",
"badge": null,
"subtitle": "Sparplan ausgef\u00fchrt",
"amount": { "currency": "EUR", "value": -70.0, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "5b17cc36-67ec-4e39-9c24-a26f653634d5"
},
"eventType": "SAVINGS_PLAN_EXECUTED"
},
{
"id": "7f28cf4a-435a-4fd4-9346-5215a196a9e5",
"timestamp": "2012-10-11T02:28:16.441+0000",
"title": "Some Asset",
"icon": "logos/IDENTIFIER/v2",
"badge": null,
"subtitle": "Vorabpauschale",
"amount": { "currency": "EUR", "value": -17.03, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "7f28cf4a-435a-4fd4-9346-5215a196a9e5"
},
"eventType": "PRE_DETERMINED_TAX_BASE"
}
],
"cursors": { "after": "143dde86-1996-4017-ae80-bbdfdf6d79e8", "before": null }
}
[
{
"id": "3af95aed-76a9-4142-9c9b-d4fb2598e013",
"timestamp": "2024-02-04T15:56:33.375+0000",
"title": "Zinsen",
"icon": "logos/timeline_interest_new/v2",
"badge": null,
"subtitle": null,
"amount": { "currency": "EUR", "value": 10, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "3af95aed-76a9-4142-9c9b-d4fb2598e013"
},
"eventType": "INTEREST_PAYOUT_CREATED"
},
{
"id": "e2f5c297-79ab-4118-8a79-8ce7d53a4b41",
"timestamp": "2023-06-11T15:44:14.017+0000",
"title": "Einzahlung",
"icon": "logos/timeline_plus_circle/v2",
"badge": null,
"subtitle": null,
"amount": { "currency": "EUR", "value": 50.0, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "e2f5c297-79ab-4118-8a79-8ce7d53a4b41"
},
"eventType": "PAYMENT_INBOUND_SEPA_DIRECT_DEBIT"
},
{
"id": "5b17cc36-67ec-4e39-9c24-a26f653634d5",
"timestamp": "2017-10-17T08:11:08.217+0000",
"title": "Some Asset",
"icon": "logos/IDENTIFIER/v2",
"badge": null,
"subtitle": "Sparplan ausgef\u00fchrt",
"amount": { "currency": "EUR", "value": -70.0, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "5b17cc36-67ec-4e39-9c24-a26f653634d5"
},
"eventType": "SAVINGS_PLAN_EXECUTED"
},
{
"id": "7f28cf4a-435a-4fd4-9346-5215a196a9e5",
"timestamp": "2012-10-11T02:28:16.441+0000",
"title": "Some Asset",
"icon": "logos/IDENTIFIER/v2",
"badge": null,
"subtitle": "Vorabpauschale",
"amount": { "currency": "EUR", "value": -17.03, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "7f28cf4a-435a-4fd4-9346-5215a196a9e5"
},
"eventType": "PRE_DETERMINED_TAX_BASE"
}
]
39 changes: 18 additions & 21 deletions packages/ynap-parsers/src/de/trade-republic/trade-republic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@ import { YnabFile } from '../..'
import { encode } from 'iconv-lite'

const content = encode(
`{
"items": [
{
"id": "3af95aed-76a9-4142-9c9b-d4fb2598e013",
"timestamp": "2024-02-04T15:56:33.375+0000",
"title": "Zinsen",
"icon": "logos/timeline_interest_new/v2",
"badge": null,
"subtitle": null,
"amount": { "currency": "EUR", "value": 10, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "3af95aed-76a9-4142-9c9b-d4fb2598e013"
},
"eventType": "INTEREST_PAYOUT_CREATED"
}
],
"cursors": { "after": "143dde86-1996-4017-ae80-bbdfdf6d79e8", "before": null }
}`,
`[
{
"id": "3af95aed-76a9-4142-9c9b-d4fb2598e013",
"timestamp": "2024-02-04T15:56:33.375+0000",
"title": "Zinsen",
"icon": "logos/timeline_interest_new/v2",
"badge": null,
"subtitle": null,
"amount": { "currency": "EUR", "value": 10, "fractionDigits": 2 },
"subAmount": null,
"status": "EXECUTED",
"action": {
"type": "timelineDetail",
"payload": "3af95aed-76a9-4142-9c9b-d4fb2598e013"
},
"eventType": "INTEREST_PAYOUT_CREATED"
}
]`,
'utf-8'
)

Expand Down
4 changes: 2 additions & 2 deletions packages/ynap-parsers/src/de/trade-republic/trade-republic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const generateYnabDate = (input: string) => {

export const tradeRepublicParser: ParserFunction = async (file: File) => {
const fileString = await readEncodedFile(file)
const data = await JSON.parse(fileString)['items']
const data = await JSON.parse(fileString)

return [
{
Expand Down Expand Up @@ -56,7 +56,7 @@ export const tradeRepublicMatcher: MatcherFunction = async (file: File) => {

try {
const data = await JSON.parse(rawFileString)
const first = data.items[0]
const first = data[0]
if (generateYnabDate(first.timestamp) && first.eventType) {
return true
}
Expand Down

0 comments on commit c940d5a

Please sign in to comment.