Skip to content

Commit

Permalink
Add interest correction as fee
Browse files Browse the repository at this point in the history
  • Loading branch information
dickwolff committed Jan 19, 2025
1 parent 18b91b5 commit 0c0180c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion samples/xtb-export.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion src/converters/xtbConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!"); });
Expand Down
13 changes: 13 additions & 0 deletions src/converters/xtbConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) => {

Expand Down

0 comments on commit 0c0180c

Please sign in to comment.