Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/add missing dates to edit historical market data in asset profile details dialog (#3206)

Fedrona668a66e84ef
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8295463dd..6b5da11683 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Fixed
+
+- Added missing dates to edit historical market data in the asset profile details dialog of the admin control panel
+
## 2.68.0 - 2024-03-29
### Added
diff --git a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html
index f452dd1c97..00551bc998 100644
--- a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html
+++ b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.html
@@ -9,11 +9,7 @@
[showYAxis]="true"
[symbol]="symbol"
/>
- <div
- *ngFor="let itemByMonth of marketDataByMonth | keyvalue"
- class="d-flex"
- [hidden]="!marketData.length > 0"
- >
+ <div *ngFor="let itemByMonth of marketDataByMonth | keyvalue" class="d-flex">
<div class="date px-1 text-nowrap">{{ itemByMonth.key }}</div>
<div class="align-items-center d-flex flex-grow-1 px-1">
<div
diff --git a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts
index 26da886e77..7e7168a6e5 100644
--- a/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts
+++ b/apps/client/src/app/components/admin-market-data-detail/admin-market-data-detail.component.ts
@@ -19,15 +19,17 @@ import { MatDialog } from '@angular/material/dialog';
import { DataSource, MarketData } from '@prisma/client';
import {
addDays,
+ addMonths,
format,
isBefore,
isSameDay,
isToday,
isValid,
+ min,
parse,
parseISO
} from 'date-fns';
-import { last } from 'lodash';
+import { first, last } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject, takeUntil } from 'rxjs';
@@ -135,6 +137,27 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
marketPrice: marketDataItem.marketPrice
};
}
+
+ if (this.dateOfFirstActivity) {
+ // Fill up missing months
+ const dates = Object.keys(this.marketDataByMonth).sort();
+ const startDate = min([
+ parseISO(this.dateOfFirstActivity),
+ parseISO(first(dates))
+ ]);
+ const endDate = parseISO(last(dates));
+
+ let currentDate = startDate;
+
+ while (isBefore(currentDate, endDate)) {
+ const key = format(currentDate, 'yyyy-MM');
+ if (!this.marketDataByMonth[key]) {
+ this.marketDataByMonth[key] = {};
+ }
+
+ currentDate = addMonths(currentDate, 1);
+ }
+ }
}
public isDateOfInterest(aDateString: string) {