Skip to content

Commit

Permalink
Fix transaction timestamp mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
dickwolff committed Jun 3, 2024
1 parent ff9f40e commit acc3444
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/converters/abstractConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@ 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()));

// Act
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()", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/converters/abstractconverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/converters/buxConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down Expand Up @@ -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,
Expand All @@ -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
});

Expand Down
2 changes: 1 addition & 1 deletion src/models/buxRecord.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class BuxRecord {
transactionTime: Date;
transactionTimeCet: Date;
transactionCategory: string;
transactionType: string;
assetId: string;
Expand Down

0 comments on commit acc3444

Please sign in to comment.