diff --git a/samples/xtb-export.csv b/samples/xtb-export.csv index 2ab6e07b..4905a65b 100644 --- a/samples/xtb-export.csv +++ b/samples/xtb-export.csv @@ -35,4 +35,5 @@ ID;Type;Time;Symbol;Comment;Amount 579262886;Dividend;12.07.2024 13:01:17;XRAY.US;XRAY.US USD 0.1600/ SHR;4.8 547615089;Stocks/ETF purchase;14.05.2024 17:21:10;FLOA.UK;OPEN BUY 16/16.7399 @ 5.9140;-94.62 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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src/converters/xtbConverter.test.ts b/src/converters/xtbConverter.test.ts index f3a2a43b..c2360ea7 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(26); + expect(actualExport.activities.length).toBe(27); done(); }, () => { done.fail("Should not have an error!"); }); diff --git a/src/converters/xtbConverter.ts b/src/converters/xtbConverter.ts index b4398f10..8b6b468a 100644 --- a/src/converters/xtbConverter.ts +++ b/src/converters/xtbConverter.ts @@ -41,12 +41,17 @@ export class XtbConverter extends AbstractConverter { else if (type.indexOf("stocks/etf sale") > -1 || type.indexOf("ações/etf vende") > -1) { return "sell"; } + else if ( + type.indexOf("sec fee") > -1 || + type.indexOf("swap") > -1 || + type.indexOf("commission") > -1 || + type.indexOf("free funds interests tax") > -1) { + + return "fee"; + } else if (type.indexOf("free funds interests") > -1) { return "interest"; } - else if (type.indexOf("sec fee") > -1 || type.indexOf("swap") > -1 || type.indexOf("commission") > -1) { - return "fee"; - } else if (type.indexOf("dividend") > -1) { return "dividend"; } @@ -122,7 +127,7 @@ export class XtbConverter extends AbstractConverter { fee: 0, quantity: 1, type: GhostfolioOrderType[record.type], - unitPrice: record.amount, + unitPrice: Math.abs(record.amount), currency: process.env.XTB_ACCOUNT_CURRENCY || "EUR", dataSource: "MANUAL", date: date.format("YYYY-MM-DDTHH:mm:ssZ"),