Browse Source

Feature/hide irrelevant errors in client (#1623)

* Hide irrelevant errors in client

* Update changelog
pull/1624/head^2
Thomas Kaul 2 years ago
committed by GitHub
parent
commit
6cd51fb044
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 2
      apps/api/src/app/portfolio/portfolio-calculator.ts
  3. 52
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 9
      apps/client/src/app/components/home-overview/home-overview.component.ts
  5. 1
      apps/client/src/app/components/home-overview/home-overview.html
  6. 4
      apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html
  7. 1
      apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

1
CHANGELOG.md

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Removed the toggle _Original Shares_ vs. _Current Shares_ on the allocations page - Removed the toggle _Original Shares_ vs. _Current Shares_ on the allocations page
- Hid error messages related to no current investment in the client
### Fixed ### Fixed

2
apps/api/src/app/portfolio/portfolio-calculator.ts

@ -447,7 +447,7 @@ export class PortfolioCalculator {
transactionCount: item.transactionCount transactionCount: item.transactionCount
}); });
if (hasErrors) { if (hasErrors && item.investment.gt(0)) {
errors.push({ dataSource: item.dataSource, symbol: item.symbol }); errors.push({ dataSource: item.dataSource, symbol: item.symbol });
} }
} }

52
apps/api/src/app/portfolio/portfolio.service.ts

@ -1039,29 +1039,21 @@ export class PortfolioService {
const portfolioStart = parseDate(transactionPoints[0].date); const portfolioStart = parseDate(transactionPoints[0].date);
const startDate = this.getStartDate(dateRange, portfolioStart); const startDate = this.getStartDate(dateRange, portfolioStart);
const currentPositions = await portfolioCalculator.getCurrentPositions( const {
startDate currentValue,
); errors,
grossPerformance,
grossPerformancePercentage,
hasErrors,
netPerformance,
netPerformancePercentage,
totalInvestment
} = await portfolioCalculator.getCurrentPositions(startDate);
const hasErrors = currentPositions.hasErrors; const currentGrossPerformance = grossPerformance;
const currentValue = currentPositions.currentValue.toNumber(); const currentGrossPerformancePercent = grossPerformancePercentage;
const currentGrossPerformance = currentPositions.grossPerformance; let currentNetPerformance = netPerformance;
const currentGrossPerformancePercent = let currentNetPerformancePercent = netPerformancePercentage;
currentPositions.grossPerformancePercentage;
let currentNetPerformance = currentPositions.netPerformance;
let currentNetPerformancePercent =
currentPositions.netPerformancePercentage;
const totalInvestment = currentPositions.totalInvestment;
// if (currentGrossPerformance.mul(currentGrossPerformancePercent).lt(0)) {
// // If algebraic sign is different, harmonize it
// currentGrossPerformancePercent = currentGrossPerformancePercent.mul(-1);
// }
// if (currentNetPerformance.mul(currentNetPerformancePercent).lt(0)) {
// // If algebraic sign is different, harmonize it
// currentNetPerformancePercent = currentNetPerformancePercent.mul(-1);
// }
const historicalDataContainer = await this.getChart({ const historicalDataContainer = await this.getChart({
dateRange, dateRange,
@ -1083,28 +1075,28 @@ export class PortfolioService {
} }
return { return {
errors,
hasErrors,
chart: historicalDataContainer.items.map( chart: historicalDataContainer.items.map(
({ ({
date, date,
netPerformance, netPerformance: netPerformanceOfItem,
netPerformanceInPercentage, netPerformanceInPercentage,
totalInvestment, totalInvestment: totalInvestmentOfItem,
value value
}) => { }) => {
return { return {
date, date,
netPerformance,
netPerformanceInPercentage, netPerformanceInPercentage,
totalInvestment, value,
value netPerformance: netPerformanceOfItem,
totalInvestment: totalInvestmentOfItem
}; };
} }
), ),
errors: currentPositions.errors,
firstOrderDate: parseDate(historicalDataContainer.items[0]?.date), firstOrderDate: parseDate(historicalDataContainer.items[0]?.date),
hasErrors: currentPositions.hasErrors || hasErrors,
performance: { performance: {
currentValue, currentValue: currentValue.toNumber(),
currentGrossPerformance: currentGrossPerformance.toNumber(), currentGrossPerformance: currentGrossPerformance.toNumber(),
currentGrossPerformancePercent: currentGrossPerformancePercent:
currentGrossPerformancePercent.toNumber(), currentGrossPerformancePercent.toNumber(),

9
apps/client/src/app/components/home-overview/home-overview.component.ts

@ -110,13 +110,12 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
range: this.user?.settings?.dateRange range: this.user?.settings?.dateRange
}) })
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe((response) => { .subscribe(({ chart, errors, performance }) => {
this.errors = response.errors; this.errors = errors;
this.hasError = response.hasErrors; this.performance = performance;
this.performance = response.performance;
this.isLoadingPerformance = false; this.isLoadingPerformance = false;
this.historicalDataItems = response.chart.map( this.historicalDataItems = chart.map(
({ date, netPerformanceInPercentage }) => { ({ date, netPerformanceInPercentage }) => {
return { return {
date, date,

1
apps/client/src/app/components/home-overview/home-overview.html

@ -37,7 +37,6 @@
[baseCurrency]="user?.settings?.baseCurrency" [baseCurrency]="user?.settings?.baseCurrency"
[deviceType]="deviceType" [deviceType]="deviceType"
[errors]="errors" [errors]="errors"
[hasError]="hasError"
[isAllTimeHigh]="isAllTimeHigh" [isAllTimeHigh]="isAllTimeHigh"
[isAllTimeLow]="isAllTimeLow" [isAllTimeLow]="isAllTimeLow"
[isLoading]="isLoadingPerformance" [isLoading]="isLoadingPerformance"

4
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.html

@ -3,14 +3,14 @@
<div <div
class="flex-grow-1 status text-muted text-right" class="flex-grow-1 status text-muted text-right"
[title]=" [title]="
hasError && !isLoading errors?.length > 0 && !isLoading
? 'Sorry! Our data provider partner is experiencing the hiccups.' ? 'Sorry! Our data provider partner is experiencing the hiccups.'
: '' : ''
" "
(click)="errors?.length > 0 && onShowErrors()" (click)="errors?.length > 0 && onShowErrors()"
> >
<ion-icon <ion-icon
*ngIf="hasError && !isLoading" *ngIf="errors?.length > 0 && !isLoading"
name="alert-circle-outline" name="alert-circle-outline"
></ion-icon> ></ion-icon>
</div> </div>

1
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

@ -28,7 +28,6 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit {
@Input() baseCurrency: string; @Input() baseCurrency: string;
@Input() deviceType: string; @Input() deviceType: string;
@Input() errors: ResponseError['errors']; @Input() errors: ResponseError['errors'];
@Input() hasError: boolean;
@Input() isAllTimeHigh: boolean; @Input() isAllTimeHigh: boolean;
@Input() isAllTimeLow: boolean; @Input() isAllTimeLow: boolean;
@Input() isLoading: boolean; @Input() isLoading: boolean;

Loading…
Cancel
Save