Bugfix/improve show condition of button to fetch current market price (#4700)

* Improve show condition of button to fetch current market price

* Update changelog
This commit is contained in:
Thomas Kaul 2025-05-20 22:53:32 +01:00 committed by GitHub
parent f4ef91e3be
commit a06872b657
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View File

@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Displayed the button to fetch the current market price only if the activity is not in a custom currency
- Fixed an issue in the watchlist endpoint (`POST`) related to the `HasPermissionGuard`
## 2.161.0 - 2025-05-06

View File

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

View File

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