Bugfix/fix import validation for numbers equal zero (#875)

* Fix import validation for numbers equal 0

* Update changelog
pull/877/head
Thomas Kaul 3 years ago committed by GitHub
parent 1f0bd5a7db
commit 4dc76817ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed the import validation for numbers equal 0
- Fixed the color of the spinner in the activities filter component (dark mode)
## 1.143.0 - 26.04.2022

@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto';
import { Account, DataSource, Type } from '@prisma/client';
import { parse } from 'date-fns';
import { isNumber } from 'lodash';
import { isFinite } from 'lodash';
import { parse as csvToJson } from 'papaparse';
import { EMPTY } from 'rxjs';
import { catchError } from 'rxjs/operators';
@ -185,7 +185,7 @@ export class ImportTransactionsService {
item = this.lowercaseKeys(item);
for (const key of ImportTransactionsService.FEE_KEYS) {
if ((item[key] || item[key] === 0) && isNumber(item[key])) {
if (isFinite(item[key])) {
return item[key];
}
}
@ -208,7 +208,7 @@ export class ImportTransactionsService {
item = this.lowercaseKeys(item);
for (const key of ImportTransactionsService.QUANTITY_KEYS) {
if (item[key] && isNumber(item[key])) {
if (isFinite(item[key])) {
return item[key];
}
}
@ -288,7 +288,7 @@ export class ImportTransactionsService {
item = this.lowercaseKeys(item);
for (const key of ImportTransactionsService.UNIT_PRICE_KEYS) {
if (item[key] && isNumber(item[key])) {
if (isFinite(item[key])) {
return item[key];
}
}

@ -2,3 +2,4 @@ Date,Code,Currency,Price,Quantity,Action,Fee
17/11/2021,MSFT,USD,0.62,5,dividend,0.00
16/09/2021,MSFT,USD,298.580,5,buy,19.00
01/01/2022,Penthouse Apartment,USD,500000.0,1,item,0.00
06/06/2050,MSFT,USD,0.00,0,buy,0.00

1 Date Code Currency Price Quantity Action Fee
2 17/11/2021 MSFT USD 0.62 5 dividend 0.00
3 16/09/2021 MSFT USD 298.580 5 buy 19.00
4 01/01/2022 Penthouse Apartment USD 500000.0 1 item 0.00
5 06/06/2050 MSFT USD 0.00 0 buy 0.00

@ -5,34 +5,43 @@
},
"activities": [
{
"accountId": null,
"date": "2021-12-31T23:00:00.000Z",
"fee": 0,
"quantity": 0,
"type": "BUY",
"unitPrice": 0,
"currency": "USD",
"dataSource": "YAHOO",
"date": "2050-06-05T22:00:00.000Z",
"symbol": "MSFT"
},
{
"fee": 0,
"quantity": 1,
"type": "ITEM",
"unitPrice": 500000,
"currency": "USD",
"dataSource": "MANUAL",
"date": "2021-12-31T22:00:00.000Z",
"symbol": "Penthouse Apartment"
},
{
"date": "2021-11-16T23:00:00.000Z",
"fee": 0,
"quantity": 5,
"type": "DIVIDEND",
"unitPrice": 0.62,
"currency": "USD",
"dataSource": "YAHOO",
"date": "2021-11-16T22:00:00.000Z",
"symbol": "MSFT"
},
{
"date": "2021-09-15T22:00:00.000Z",
"fee": 19,
"quantity": 5,
"type": "BUY",
"unitPrice": 298.58,
"currency": "USD",
"dataSource": "YAHOO",
"date": "2021-09-15T22:00:00.000Z",
"symbol": "MSFT"
}
]

Loading…
Cancel
Save