Improve validation of activities import (#2496)
* Improve validation of activities import: expects positive values for fee, quantity and unitPrice * Update changelog --------- Co-authored-by: Rafael Claudio <rafacla@github.com> Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>
This commit is contained in:
parent
fa627f686f
commit
2dcc7e161c
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Improved the style and wording of the position detail dialog
|
- Improved the style and wording of the position detail dialog
|
||||||
|
- Improved the validation in the activities import (expects positive values for `fee`, `quantity` and `unitPrice`)
|
||||||
- Changed the currency selector in the create or update account dialog to `@angular/material/autocomplete`
|
- Changed the currency selector in the create or update account dialog to `@angular/material/autocomplete`
|
||||||
- Upgraded `uuid` from version `9.0.0` to `9.0.1`
|
- Upgraded `uuid` from version `9.0.0` to `9.0.1`
|
||||||
- Upgraded `yahoo-finance2` from version `2.8.0` to `2.8.1`
|
- Upgraded `yahoo-finance2` from version `2.8.0` to `2.8.1`
|
||||||
|
@ -13,7 +13,9 @@ import {
|
|||||||
IsISO8601,
|
IsISO8601,
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString
|
IsPositive,
|
||||||
|
IsString,
|
||||||
|
Min
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { isString } from 'lodash';
|
import { isString } from 'lodash';
|
||||||
|
|
||||||
@ -48,9 +50,11 @@ export class CreateOrderDto {
|
|||||||
date: string;
|
date: string;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@Min(0)
|
||||||
fee: number;
|
fee: number;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@IsPositive()
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@ -64,6 +68,7 @@ export class CreateOrderDto {
|
|||||||
type: Type;
|
type: Type;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@IsPositive()
|
||||||
unitPrice: number;
|
unitPrice: number;
|
||||||
|
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
|
@ -13,7 +13,9 @@ import {
|
|||||||
IsISO8601,
|
IsISO8601,
|
||||||
IsNumber,
|
IsNumber,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString
|
IsPositive,
|
||||||
|
IsString,
|
||||||
|
Min
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { isString } from 'lodash';
|
import { isString } from 'lodash';
|
||||||
|
|
||||||
@ -47,12 +49,14 @@ export class UpdateOrderDto {
|
|||||||
date: string;
|
date: string;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@Min(0)
|
||||||
fee: number;
|
fee: number;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@IsPositive()
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@ -66,5 +70,6 @@ export class UpdateOrderDto {
|
|||||||
type: Type;
|
type: Type;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@IsPositive()
|
||||||
unitPrice: number;
|
unitPrice: number;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ export class ImportActivitiesService {
|
|||||||
|
|
||||||
for (const key of ImportActivitiesService.QUANTITY_KEYS) {
|
for (const key of ImportActivitiesService.QUANTITY_KEYS) {
|
||||||
if (isFinite(item[key])) {
|
if (isFinite(item[key])) {
|
||||||
return item[key];
|
return Math.abs(item[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ export class ImportActivitiesService {
|
|||||||
|
|
||||||
for (const key of ImportActivitiesService.UNIT_PRICE_KEYS) {
|
for (const key of ImportActivitiesService.UNIT_PRICE_KEYS) {
|
||||||
if (isFinite(item[key])) {
|
if (isFinite(item[key])) {
|
||||||
return item[key];
|
return Math.abs(item[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user