Browse Source

Merge branch 'main' into task/refactor-rounding-logic-in-holding-detail-dialog

pull/7199/head
Thomas Kaul 2 months ago
committed by GitHub
parent
commit
c01b885c60
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      CHANGELOG.md
  2. 9
      apps/api/src/app/admin/admin.controller.ts
  3. 9
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.controller.ts
  4. 3
      apps/api/src/app/import/import.service.ts
  5. 25
      libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

3
CHANGELOG.md

@ -10,8 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Refactored the rounding logic in the holding detail dialog - Refactored the rounding logic in the holding detail dialog
- Refactored the rounding logic in the treemap chart component
- Restricted the modification of activity tags in the impersonation mode - Restricted the modification of activity tags in the impersonation mode
- Hardened the endpoint of the public access for portfolio sharing by restricting it to public accesses - Hardened the endpoint of the public access for portfolio sharing by restricting it to public accesses
- Improved the parsing of integer query parameters (`skip` and `take`) in the `GET api/v1/admin/user` endpoint
- Improved the parsing of integer query parameters (`skip` and `take`) in the `GET api/v1/asset-profiles` endpoint
- Improved the language localization by translating various tooltips across the application - Improved the language localization by translating various tooltips across the application
- Improved the language localization for Ukrainian (`uk`) - Improved the language localization for Ukrainian (`uk`)
- Upgraded `yahoo-finance2` from version `3.14.3` to `3.15.4` - Upgraded `yahoo-finance2` from version `3.14.3` to `3.15.4`

9
apps/api/src/app/admin/admin.controller.ts

@ -40,6 +40,7 @@ import {
Inject, Inject,
Logger, Logger,
Param, Param,
ParseIntPipe,
Patch, Patch,
Post, Post,
Put, Put,
@ -319,12 +320,12 @@ export class AdminController {
@HasPermission(permissions.accessAdminControl) @HasPermission(permissions.accessAdminControl)
@UseGuards(AuthGuard('jwt'), HasPermissionGuard) @UseGuards(AuthGuard('jwt'), HasPermissionGuard)
public async getUsers( public async getUsers(
@Query('skip') skip?: number, @Query('skip', new ParseIntPipe({ optional: true })) skip?: number,
@Query('take') take?: number @Query('take', new ParseIntPipe({ optional: true })) take?: number
): Promise<AdminUsersResponse> { ): Promise<AdminUsersResponse> {
return this.adminService.getUsers({ return this.adminService.getUsers({
skip: isNaN(skip) ? undefined : skip, skip,
take: isNaN(take) ? undefined : take take
}); });
} }

9
apps/api/src/app/endpoints/asset-profiles/asset-profiles.controller.ts

@ -22,6 +22,7 @@ import {
HttpException, HttpException,
Inject, Inject,
Param, Param,
ParseIntPipe,
Patch, Patch,
Query, Query,
UseGuards, UseGuards,
@ -51,10 +52,10 @@ export class AssetProfilesController {
@Query('dataSource') filterByDataSource?: string, @Query('dataSource') filterByDataSource?: string,
@Query('presetId') presetId?: MarketDataPreset, @Query('presetId') presetId?: MarketDataPreset,
@Query('query') filterBySearchQuery?: string, @Query('query') filterBySearchQuery?: string,
@Query('skip') skip?: number, @Query('skip', new ParseIntPipe({ optional: true })) skip?: number,
@Query('sortColumn') sortColumn?: string, @Query('sortColumn') sortColumn?: string,
@Query('sortDirection') sortDirection?: Prisma.SortOrder, @Query('sortDirection') sortDirection?: Prisma.SortOrder,
@Query('take') take?: number @Query('take', new ParseIntPipe({ optional: true })) take?: number
): Promise<AssetProfilesResponse> { ): Promise<AssetProfilesResponse> {
const filters = this.apiService.buildFiltersFromQueryParams({ const filters = this.apiService.buildFiltersFromQueryParams({
filterByAssetSubClasses, filterByAssetSubClasses,
@ -65,10 +66,10 @@ export class AssetProfilesController {
return this.assetProfilesService.getAssetProfiles({ return this.assetProfilesService.getAssetProfiles({
filters, filters,
presetId, presetId,
skip,
sortColumn, sortColumn,
sortDirection, sortDirection,
skip: isNaN(skip) ? undefined : skip, take
take: isNaN(take) ? undefined : take
}); });
} }

3
apps/api/src/app/import/import.service.ts

@ -69,8 +69,7 @@ export class ImportService {
const holding = await this.portfolioService.getHolding({ const holding = await this.portfolioService.getHolding({
dataSource, dataSource,
symbol, symbol,
userId, userId
impersonationId: undefined
}); });
if (!holding) { if (!holding) {

25
libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

@ -30,7 +30,7 @@ import { Chart, Tooltip } from 'chart.js';
import { TreemapController, TreemapElement } from 'chartjs-chart-treemap'; import { TreemapController, TreemapElement } from 'chartjs-chart-treemap';
import { isUUID } from 'class-validator'; import { isUUID } from 'class-validator';
import { differenceInDays, max } from 'date-fns'; import { differenceInDays, max } from 'date-fns';
import { orderBy } from 'lodash'; import { orderBy, round } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import OpenColor from 'open-color'; import OpenColor from 'open-color';
@ -221,9 +221,10 @@ export class GfTreemapChartComponent
) )
}).toNumber(); }).toNumber();
// Round to 2 decimal places annualizedNetPerformancePercent = round(
annualizedNetPerformancePercent = annualizedNetPerformancePercent,
Math.round(annualizedNetPerformancePercent * 100) / 100; 2
);
const { backgroundColor } = this.getColor({ const { backgroundColor } = this.getColor({
annualizedNetPerformancePercent, annualizedNetPerformancePercent,
@ -252,9 +253,10 @@ export class GfTreemapChartComponent
) )
}).toNumber(); }).toNumber();
// Round to 2 decimal places annualizedNetPerformancePercent = round(
annualizedNetPerformancePercent = annualizedNetPerformancePercent,
Math.round(annualizedNetPerformancePercent * 100) / 100; 2
);
const { fontColor } = this.getColor({ const { fontColor } = this.getColor({
annualizedNetPerformancePercent, annualizedNetPerformancePercent,
@ -267,11 +269,10 @@ export class GfTreemapChartComponent
display: true, display: true,
font: [{ size: 16 }, { lineHeight: 1.5, size: 14 }], font: [{ size: 16 }, { lineHeight: 1.5, size: 14 }],
formatter: ({ raw }: GfTreemapScriptableContext) => { formatter: ({ raw }: GfTreemapScriptableContext) => {
// Round to 4 decimal places let netPerformancePercentWithCurrencyEffect = round(
let netPerformancePercentWithCurrencyEffect = raw._data.netPerformancePercentWithCurrencyEffect,
Math.round( 4
raw._data.netPerformancePercentWithCurrencyEffect * 10000 );
) / 10000;
if (Math.abs(netPerformancePercentWithCurrencyEffect) === 0) { if (Math.abs(netPerformancePercentWithCurrencyEffect) === 0) {
netPerformancePercentWithCurrencyEffect = Math.abs( netPerformancePercentWithCurrencyEffect = Math.abs(

Loading…
Cancel
Save