Browse Source

Improve show condition of button to fetch current market price

pull/4700/head
Thomas Kaul 4 months ago
parent
commit
3c09c0915f
  1. 12
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
  2. 4
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html

12
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts

@ -39,6 +39,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
return { id: assetSubClass, label: translate(assetSubClass) }; return { id: assetSubClass, label: translate(assetSubClass) };
}); });
public currencies: string[] = []; public currencies: string[] = [];
public currencyOfAssetProfile: string;
public currentMarketPrice = null; public currentMarketPrice = null;
public defaultDateFormat: string; public defaultDateFormat: string;
public isLoading = false; public isLoading = false;
@ -63,8 +64,10 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
) {} ) {}
public ngOnInit() { public ngOnInit() {
this.mode = this.data.activity.id ? 'update' : 'create'; this.currencyOfAssetProfile = this.data.activity?.SymbolProfile?.currency;
this.locale = this.data.user?.settings?.locale; this.locale = this.data.user?.settings?.locale;
this.mode = this.data.activity?.id ? 'update' : 'create';
this.dateAdapter.setLocale(this.locale); this.dateAdapter.setLocale(this.locale);
const { currencies, platforms } = this.dataService.fetchInfo(); const { currencies, platforms } = this.dataService.fetchInfo();
@ -210,7 +213,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.activityForm.get('type').value this.activityForm.get('type').value
) )
) { ) {
this.updateSymbol(); this.updateAssetProfile();
} }
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
@ -397,7 +400,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.dialogRef.close(activity); this.dialogRef.close(activity);
} else { } else {
(activity as UpdateOrderDto).id = this.data.activity.id; (activity as UpdateOrderDto).id = this.data.activity?.id;
await validateObjectForForm({ await validateObjectForForm({
classDto: UpdateOrderDto, classDto: UpdateOrderDto,
@ -422,7 +425,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.unsubscribeSubject.complete(); this.unsubscribeSubject.complete();
} }
private updateSymbol() { private updateAssetProfile() {
this.isLoading = true; this.isLoading = true;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
@ -450,6 +453,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.activityForm.get('dataSource').setValue(dataSource); this.activityForm.get('dataSource').setValue(dataSource);
} }
this.currencyOfAssetProfile = currency;
this.currentMarketPrice = marketPrice; this.currentMarketPrice = marketPrice;
this.isLoading = false; this.isLoading = false;

4
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html

@ -230,8 +230,10 @@
</div> </div>
</mat-form-field> </mat-form-field>
@if ( @if (
currencyOfAssetProfile ===
activityForm.get('currencyOfUnitPrice').value &&
currentMarketPrice && currentMarketPrice &&
(data.activity.type === 'BUY' || data.activity.type === 'SELL') && ['BUY', 'SELL'].includes(data.activity.type) &&
isToday(activityForm.get('date')?.value) isToday(activityForm.get('date')?.value)
) { ) {
<button <button

Loading…
Cancel
Save