From acc34449f41f3b881062ff11a096cf552a67fc3c Mon Sep 17 00:00:00 2001 From: Dick Wolff Date: Mon, 3 Jun 2024 21:01:55 +0200 Subject: [PATCH] Fix transaction timestamp mapping --- src/converters/abstractConverter.test.ts | 5 +++-- src/converters/abstractconverter.ts | 2 ++ src/converters/buxConverter.ts | 6 +++--- src/models/buxRecord.ts | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/converters/abstractConverter.test.ts b/src/converters/abstractConverter.test.ts index bcc1d72..26dda13 100644 --- a/src/converters/abstractConverter.test.ts +++ b/src/converters/abstractConverter.test.ts @@ -49,7 +49,7 @@ describe("abstractConverter", () => { // Arrange let tempFileContent = ""; - tempFileContent += "Type,ISIN,PriceInEUR,PriceInCHF\n"; + tempFileContent += "Type,ISIN,PriceInEUR,PriceInCHF,TransactionTimeCET\n"; const sut = new TestAbstractConverter(new SecurityService(new YahooFinanceServiceMock())); @@ -57,10 +57,11 @@ describe("abstractConverter", () => { const headers = sut.processHeadersTest(tempFileContent, ","); // Assert - expect(headers.length).toBe(4); + expect(headers.length).toBe(5); expect(headers[1]).toBe("isin"); expect(headers[2]).toBe("priceInEur"); expect(headers[3]).toBe("priceInChf"); + expect(headers[4]).toBe("transactionTimeCet"); }); describe("logQueryError()", () => { diff --git a/src/converters/abstractconverter.ts b/src/converters/abstractconverter.ts index eddb966..a4520da 100644 --- a/src/converters/abstractconverter.ts +++ b/src/converters/abstractconverter.ts @@ -88,6 +88,8 @@ export abstract class AbstractConverter { col = col.slice(0, -3) + "Eur"; } else if (col.endsWith("CHF")) { col = col.slice(0, -3) + "Chf"; + } else if (col.endsWith("CET")) { + col = col.slice(0, -3) + "Cet"; } csvHeaders.push(col); diff --git a/src/converters/buxConverter.ts b/src/converters/buxConverter.ts index 196fde6..07a5751 100644 --- a/src/converters/buxConverter.ts +++ b/src/converters/buxConverter.ts @@ -110,7 +110,7 @@ export class BuxConverter extends AbstractConverter { unitPrice: feeAmount, currency: record.transactionCurrency, dataSource: "MANUAL", - date: dayjs(record.transactionTime).format("YYYY-MM-DDTHH:mm:ssZ"), + date: dayjs(record.transactionTimeCet).format("YYYY-MM-DDTHH:mm:ssZ"), symbol: record.assetName }); @@ -148,7 +148,7 @@ export class BuxConverter extends AbstractConverter { quantity = record.tradeQuantity; unitPrice = record.tradePrice; } - +console.log(record) // Add record to export. result.activities.push({ accountId: process.env.GHOSTFOLIO_ACCOUNT_ID, @@ -159,7 +159,7 @@ export class BuxConverter extends AbstractConverter { unitPrice: unitPrice, currency: record.transactionCurrency, dataSource: "YAHOO", - date: dayjs(record.transactionTime).format("YYYY-MM-DDTHH:mm:ssZ"), + date: dayjs(record.transactionTimeCet).format("YYYY-MM-DDTHH:mm:ssZ"), symbol: security.symbol }); diff --git a/src/models/buxRecord.ts b/src/models/buxRecord.ts index 7e21b78..a6fe9e2 100644 --- a/src/models/buxRecord.ts +++ b/src/models/buxRecord.ts @@ -1,5 +1,5 @@ export class BuxRecord { - transactionTime: Date; + transactionTimeCet: Date; transactionCategory: string; transactionType: string; assetId: string;