diff --git a/GitVersion.yml b/GitVersion.yml index a51dbd6..d852420 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,4 +1,4 @@ -next-version: 0.7.2 +next-version: 0.7.3 assembly-informational-format: "{NuGetVersion}" mode: ContinuousDeployment branches: diff --git a/src/converters/degiroConverterV2.test.ts b/src/converters/degiroConverterV2.test.ts index 983a8b6..48bfc5b 100644 --- a/src/converters/degiroConverterV2.test.ts +++ b/src/converters/degiroConverterV2.test.ts @@ -5,7 +5,7 @@ import { GhostfolioExport } from "../models/ghostfolioExport"; describe("degiroConverterV2", () => { beforeEach(() => { - jest.spyOn(console, "log").mockImplementation(jest.fn()); + // jest.spyOn(console, "log").mockImplementation(jest.fn()); }); afterEach(() => { @@ -33,7 +33,7 @@ describe("degiroConverterV2", () => { // Assert expect(actualExport).toBeTruthy(); expect(actualExport.activities.length).toBeGreaterThan(0); - expect(actualExport.activities.length).toBe(16); + expect(actualExport.activities.length).toBe(15); done(); }, () => { done.fail("Should not have an error!"); }); diff --git a/src/converters/degiroConverterV2.ts b/src/converters/degiroConverterV2.ts index 3776418..501aa55 100644 --- a/src/converters/degiroConverterV2.ts +++ b/src/converters/degiroConverterV2.ts @@ -130,7 +130,7 @@ export class DeGiroConverterV2 extends AbstractConverter { continue; } } - else if (this.isTransactionFeeRecord(record)) { + else if (this.isTransactionFeeRecord(record, false)) { // If it was a transaction record without any other transaction connected, skip it. bar1.increment(); @@ -223,7 +223,7 @@ export class DeGiroConverterV2 extends AbstractConverter { const nextRecord = records[currentIndex + 1]; // Return wether both records are about the same product. - return currentRecord.product === nextRecord.product; + return currentRecord.product === nextRecord.product && currentRecord.orderId === nextRecord.orderId; } private combineRecords(currentRecord: DeGiroRecord, nextRecord: DeGiroRecord, security: YahooFinanceRecord): [GhostfolioActivity, number] { @@ -236,12 +236,12 @@ export class DeGiroConverterV2 extends AbstractConverter { // Determine which of the two records is the action record (e.g. buy/sell) and which contains the transaction fees. // Firstly, check if the current record is the TxFee record. - if (this.isTransactionFeeRecord(currentRecord)) { + if (this.isTransactionFeeRecord(currentRecord, true)) { actionRecord = nextRecord; txFeeRecord = currentRecord; } // Next, check wether the next record is NOT a TxFee record. In this case, the transaction has no fees. - else if (!this.isTransactionFeeRecord(nextRecord)) { + else if (!this.isTransactionFeeRecord(nextRecord, true)) { txFeeRecord = null; } @@ -295,12 +295,12 @@ export class DeGiroConverterV2 extends AbstractConverter { // Determine which of the two records is the dividend record and which contains the transaction fees. // Firstly, check if the current record is the TxFee record. - if (this.isTransactionFeeRecord(currentRecord)) { + if (this.isTransactionFeeRecord(currentRecord, false)) { dividendRecord = nextRecord; txFeeRecord = currentRecord; } // Next, check wether the next record is NOT a TxFee record. In this case, the dividend has no fees. - else if (!this.isTransactionFeeRecord(nextRecord)) { + else if (!this.isTransactionFeeRecord(nextRecord, false)) { txFeeRecord = null; } @@ -338,9 +338,9 @@ export class DeGiroConverterV2 extends AbstractConverter { // - TxFee + Buy/Sell records, or // - Buy/Sell record without TxFee. return ( - (this.isBuyOrSellRecord(currentRecord) && this.isTransactionFeeRecord(nextRecord)) || - (this.isTransactionFeeRecord(currentRecord) && this.isBuyOrSellRecord(nextRecord) || - (this.isBuyOrSellRecord(currentRecord) && !this.isTransactionFeeRecord(nextRecord)))); + (this.isBuyOrSellRecord(currentRecord) && this.isTransactionFeeRecord(nextRecord, true)) || + (this.isTransactionFeeRecord(currentRecord, true) && this.isBuyOrSellRecord(nextRecord) || + (this.isBuyOrSellRecord(currentRecord) && !this.isTransactionFeeRecord(nextRecord, true)))); } private isDividendRecordSet(currentRecord: DeGiroRecord, nextRecord: DeGiroRecord): boolean { @@ -350,9 +350,9 @@ export class DeGiroConverterV2 extends AbstractConverter { // - TxFee + Dividend record, or // - Dividend record without TxFee. return ( - (this.isDividendRecord(currentRecord) && this.isTransactionFeeRecord(nextRecord)) || - (this.isTransactionFeeRecord(currentRecord) && this.isDividendRecord(nextRecord)) || - (this.isDividendRecord(currentRecord) && !this.isTransactionFeeRecord(nextRecord))); + (this.isDividendRecord(currentRecord) && this.isTransactionFeeRecord(nextRecord, false)) || + (this.isTransactionFeeRecord(currentRecord, false) && this.isDividendRecord(nextRecord)) || + (this.isDividendRecord(currentRecord) && !this.isTransactionFeeRecord(nextRecord, false))); } private isBuyOrSellRecord(record: DeGiroRecord): boolean { @@ -375,12 +375,17 @@ export class DeGiroConverterV2 extends AbstractConverter { return record.description.toLocaleLowerCase().indexOf("dividend") > -1 || record.description.toLocaleLowerCase().indexOf("capital return") > -1; } - private isTransactionFeeRecord(record: DeGiroRecord): boolean { + private isTransactionFeeRecord(record: DeGiroRecord, isBuyOrSellTransactionFeeRecord: boolean): boolean { if (!record) { return false; } + // When a dividend transaction must be found, there should not be an orderid. + if (!isBuyOrSellTransactionFeeRecord && record.orderId) { + return false; + } + const transactionFeeRecordType = ["en\/of", "and\/or", "und\/oder", "e\/o", "adr\/gdr", "ritenuta", "belasting", "daň z dividendy", "taxe sur les", "comissões de transação", "courtage et/ou"]; return transactionFeeRecordType.some((t) => record.description.toLocaleLowerCase().indexOf(t) > -1); diff --git a/src/models/degiroRecord.ts b/src/models/degiroRecord.ts index a943cb0..9dc275b 100644 --- a/src/models/degiroRecord.ts +++ b/src/models/degiroRecord.ts @@ -8,4 +8,5 @@ export class DeGiroRecord { fx: string; currency: string; amount: string; + orderId: string; }