From 0c0180cf70c6c1e320a215378dd4cf15765de3ce Mon Sep 17 00:00:00 2001 From: Dick Wolff Date: Sun, 19 Jan 2025 16:55:02 +0100 Subject: [PATCH] Add interest correction as fee --- samples/xtb-export.csv | 3 ++- src/converters/xtbConverter.test.ts | 2 +- src/converters/xtbConverter.ts | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/samples/xtb-export.csv b/samples/xtb-export.csv index 760bfbfd..c8b96cc3 100644 --- a/samples/xtb-export.csv +++ b/samples/xtb-export.csv @@ -37,4 +37,5 @@ ID;Type;Time;Symbol;Comment;Amount 547615042;Stocks/ETF purchase;14.05.2024 17:21:09;CSPX.UK;OPEN BUY 0.1799 @ 550.30;-99 547615041;Stocks/ETF purchase;14.05.2024 17:21:09;FLOA.UK;OPEN BUY 0.7399/16.7399 @ 5.9140;-4.38 543857396;Free funds interests tax;07.05.2024 09:36:50;;Free-funds Interest Tax 2024-04;-2 -543604525;Free funds interests;07.05.2024 03:16:39;;Free-funds Interest 2024-04;15.17 \ No newline at end of file +543604525;Free funds interests;07.05.2024 03:16:39;;Free-funds Interest 2024-04;15.17 +597124174;Free funds interests;09.08.2024 19:38:51;;Corr Free-funds Interest 2024-07;0.5 \ No newline at end of file diff --git a/src/converters/xtbConverter.test.ts b/src/converters/xtbConverter.test.ts index c2360ea7..bbf7480d 100644 --- a/src/converters/xtbConverter.test.ts +++ b/src/converters/xtbConverter.test.ts @@ -34,7 +34,7 @@ describe("xtbConverter", () => { // Assert expect(actualExport).toBeTruthy(); expect(actualExport.activities.length).toBeGreaterThan(0); - expect(actualExport.activities.length).toBe(27); + expect(actualExport.activities.length).toBe(28); done(); }, () => { done.fail("Should not have an error!"); }); diff --git a/src/converters/xtbConverter.ts b/src/converters/xtbConverter.ts index 80b42e47..01f884ff 100644 --- a/src/converters/xtbConverter.ts +++ b/src/converters/xtbConverter.ts @@ -72,6 +72,19 @@ export class XtbConverter extends AbstractConverter { } return columnValue; + }, + on_record: (record: XtbRecord) => { + + // Post processing steps. + + // If a record is typed as interest, but is a correction, then change type to fee. + if (record.type === "interest" && record.comment.toLocaleLowerCase().startsWith("corr")) { + record.type = "fee"; + } + + console.log(record); + + return record; } }, async (err, records: XtbRecord[]) => {