Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dickwolff committed Jan 6, 2025
1 parent 75ee53d commit 79fd3ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions src/converters/directaConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DirectaConverter extends AbstractConverter {
// Convert actions to Ghostfolio type.
if (context.column === "tipoOperazione") {
const action = columnValue.toLocaleLowerCase();

if (action.indexOf("acquisto") > -1) {
return "buy";
}
Expand Down Expand Up @@ -95,7 +95,7 @@ export class DirectaConverter extends AbstractConverter {
continue;
}

if(!record.dataValuta) {
if (!record.dataValuta) {
this.progress.log(`[i] No date found for record ${idx + 2}! Skipping..\n`);
bar1.increment();
continue;
Expand Down Expand Up @@ -132,8 +132,8 @@ export class DirectaConverter extends AbstractConverter {
this.progress.log(`[i] No result found for ${record.tipoOperazione} action for ${record.isin || record.ticker} with currency ${record.divisa}! Please add this manually..\n`);
bar1.increment();
continue;
}
}

const activity = this.createActivity(record, security);
if (activity) {
result.activities.push(activity);
Expand All @@ -148,14 +148,22 @@ export class DirectaConverter extends AbstractConverter {
});
}

/**
* @inheritdoc
*/
public isIgnoredRecord(record: any): boolean {
let ignoredRecordTypes = ["conferimento", "bonifico", "finanziamento", "bollo", "prelievo"];
return ignoredRecordTypes.some(t => record.tipoOperazione.toLocaleLowerCase().indexOf(t) > -1)
}

private createActivity(record: DirectaRecord, security: YahooFinanceRecord): GhostfolioActivity {
const date = dayjs(record.dataValuta, "DD-MM-YYYY");

let quantity = 0, unitPrice = 0, fee = 0;

let bondDescriptions = ["cdp obb", "romania", "btp"];
const isBond = bondDescriptions.some(t => record.descrizione.toLowerCase().indexOf(t) > -1);

switch (record.tipoOperazione) {
case "dividend":
case "interest":
Expand All @@ -169,7 +177,7 @@ export class DirectaConverter extends AbstractConverter {
default:
if (isBond) {
unitPrice = (record.importoEuro / Number(record.quantit)) * 100;
quantity = Number(record.quantit)/100;
quantity = Number(record.quantit) / 100;
} else {
quantity = Number(record.quantit);
unitPrice = record.importoEuro / quantity;
Expand All @@ -191,12 +199,4 @@ export class DirectaConverter extends AbstractConverter {
symbol: security.symbol
};
}

/**
* @inheritdoc
*/
public isIgnoredRecord(record: any): boolean {
let ignoredRecordTypes = ["conferimento", "bonifico", "finanziamento", "bollo", "prelievo"];
return ignoredRecordTypes.some(t => record.tipoOperazione.toLocaleLowerCase().indexOf(t) > -1)
}
}

0 comments on commit 79fd3ff

Please sign in to comment.