|
|
@ -1,5 +1,6 @@ |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { ASSET_CLASS_MAPPING } from '@ghostfolio/common/config'; |
|
|
import { ASSET_CLASS_MAPPING } from '@ghostfolio/common/config'; |
|
|
|
|
|
import { locale as defaultLocale } from '@ghostfolio/common/config'; |
|
|
import { CreateOrderDto, UpdateOrderDto } from '@ghostfolio/common/dtos'; |
|
|
import { CreateOrderDto, UpdateOrderDto } from '@ghostfolio/common/dtos'; |
|
|
import { getDateFormatString } from '@ghostfolio/common/helper'; |
|
|
import { getDateFormatString } from '@ghostfolio/common/helper'; |
|
|
import { |
|
|
import { |
|
|
@ -89,11 +90,11 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
|
|
|
|
|
|
public assetSubClassOptions: AssetClassSelectorOption[] = []; |
|
|
public assetSubClassOptions: AssetClassSelectorOption[] = []; |
|
|
public currencies: string[] = []; |
|
|
public currencies: string[] = []; |
|
|
public currencyOfAssetProfile: string; |
|
|
public currencyOfAssetProfile: string | undefined; |
|
|
public currentMarketPrice = null; |
|
|
public currentMarketPrice: number | null = null; |
|
|
public defaultDateFormat: string; |
|
|
public defaultDateFormat: string; |
|
|
public defaultLookupItems: LookupItem[] = []; |
|
|
public defaultLookupItems: LookupItem[] = []; |
|
|
public hasPermissionToCreateOwnTag: boolean; |
|
|
public hasPermissionToCreateOwnTag: boolean | undefined; |
|
|
public isLoading = false; |
|
|
public isLoading = false; |
|
|
public isToday = isToday; |
|
|
public isToday = isToday; |
|
|
public mode: 'create' | 'update'; |
|
|
public mode: 'create' | 'update'; |
|
|
@ -106,7 +107,7 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
@Inject(MAT_DIALOG_DATA) public data: CreateOrUpdateActivityDialogParams, |
|
|
@Inject(MAT_DIALOG_DATA) public data: CreateOrUpdateActivityDialogParams, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
private dateAdapter: DateAdapter<any>, |
|
|
private dateAdapter: DateAdapter<Date, string>, |
|
|
private destroyRef: DestroyRef, |
|
|
private destroyRef: DestroyRef, |
|
|
public dialogRef: MatDialogRef<GfCreateOrUpdateActivityDialogComponent>, |
|
|
public dialogRef: MatDialogRef<GfCreateOrUpdateActivityDialogComponent>, |
|
|
private formBuilder: FormBuilder, |
|
|
private formBuilder: FormBuilder, |
|
|
@ -121,7 +122,7 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
this.hasPermissionToCreateOwnTag = |
|
|
this.hasPermissionToCreateOwnTag = |
|
|
this.data.user?.settings?.isExperimentalFeatures && |
|
|
this.data.user?.settings?.isExperimentalFeatures && |
|
|
hasPermission(this.data.user?.permissions, permissions.createOwnTag); |
|
|
hasPermission(this.data.user?.permissions, permissions.createOwnTag); |
|
|
this.locale = this.data.user?.settings?.locale; |
|
|
this.locale = this.data.user.settings.locale ?? defaultLocale; |
|
|
this.mode = this.data.activity?.id ? 'update' : 'create'; |
|
|
this.mode = this.data.activity?.id ? 'update' : 'create'; |
|
|
|
|
|
|
|
|
this.dateAdapter.setLocale(this.locale); |
|
|
this.dateAdapter.setLocale(this.locale); |
|
|
@ -136,34 +137,25 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ holdings }) => { |
|
|
.subscribe(({ holdings }) => { |
|
|
this.defaultLookupItems = holdings |
|
|
this.defaultLookupItems = holdings |
|
|
.filter(({ assetSubClass }) => { |
|
|
.filter(({ assetProfile }) => { |
|
|
return !['CASH'].includes(assetSubClass); |
|
|
return !['CASH'].includes(assetProfile.assetSubClass); |
|
|
}) |
|
|
}) |
|
|
.sort((a, b) => { |
|
|
.sort((a, b) => { |
|
|
return a.name?.localeCompare(b.name); |
|
|
return a.name?.localeCompare(b.name); |
|
|
}) |
|
|
}) |
|
|
.map( |
|
|
.map(({ assetProfile }) => { |
|
|
({ |
|
|
return { |
|
|
assetClass, |
|
|
assetClass: assetProfile.assetClass, |
|
|
assetSubClass, |
|
|
assetSubClass: assetProfile.assetSubClass, |
|
|
currency, |
|
|
currency: assetProfile.currency ?? '', |
|
|
dataSource, |
|
|
dataProviderInfo: { |
|
|
name, |
|
|
isPremium: false |
|
|
symbol |
|
|
}, |
|
|
}) => { |
|
|
dataSource: assetProfile.dataSource, |
|
|
return { |
|
|
name: assetProfile.name ?? '', |
|
|
assetClass, |
|
|
symbol: assetProfile.symbol |
|
|
assetSubClass, |
|
|
}; |
|
|
currency, |
|
|
}); |
|
|
dataSource, |
|
|
|
|
|
name, |
|
|
|
|
|
symbol, |
|
|
|
|
|
dataProviderInfo: { |
|
|
|
|
|
isPremium: false |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
@ -242,25 +234,25 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
.subscribe(async () => { |
|
|
.subscribe(async () => { |
|
|
if ( |
|
|
if ( |
|
|
['BUY', 'FEE', 'VALUABLE'].includes( |
|
|
['BUY', 'FEE', 'VALUABLE'].includes( |
|
|
this.activityForm.get('type').value |
|
|
this.activityForm.get('type')?.value |
|
|
) |
|
|
) |
|
|
) { |
|
|
) { |
|
|
this.total = |
|
|
this.total = |
|
|
this.activityForm.get('quantity').value * |
|
|
this.activityForm.get('quantity')?.value * |
|
|
this.activityForm.get('unitPrice').value + |
|
|
this.activityForm.get('unitPrice')?.value + |
|
|
(this.activityForm.get('fee').value ?? 0); |
|
|
(this.activityForm.get('fee')?.value ?? 0); |
|
|
} else { |
|
|
} else { |
|
|
this.total = |
|
|
this.total = |
|
|
this.activityForm.get('quantity').value * |
|
|
this.activityForm.get('quantity')?.value * |
|
|
this.activityForm.get('unitPrice').value - |
|
|
this.activityForm.get('unitPrice')?.value - |
|
|
(this.activityForm.get('fee').value ?? 0); |
|
|
(this.activityForm.get('fee')?.value ?? 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.activityForm.get('accountId').valueChanges.subscribe((accountId) => { |
|
|
this.activityForm.get('accountId')?.valueChanges.subscribe((accountId) => { |
|
|
const type = this.activityForm.get('type').value; |
|
|
const type = this.activityForm.get('type')?.value; |
|
|
|
|
|
|
|
|
if (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(type)) { |
|
|
if (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(type)) { |
|
|
const currency = |
|
|
const currency = |
|
|
@ -268,15 +260,15 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
return id === accountId; |
|
|
return id === accountId; |
|
|
})?.currency ?? this.data.user.settings.baseCurrency; |
|
|
})?.currency ?? this.data.user.settings.baseCurrency; |
|
|
|
|
|
|
|
|
this.activityForm.get('currency').setValue(currency); |
|
|
this.activityForm.get('currency')?.setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice')?.setValue(currency); |
|
|
|
|
|
|
|
|
if (['FEE', 'INTEREST'].includes(type)) { |
|
|
if (['FEE', 'INTEREST'].includes(type)) { |
|
|
if (this.activityForm.get('accountId').value) { |
|
|
if (this.activityForm.get('accountId')?.value) { |
|
|
this.activityForm.get('updateAccountBalance').enable(); |
|
|
this.activityForm.get('updateAccountBalance')?.enable(); |
|
|
} else { |
|
|
} else { |
|
|
this.activityForm.get('updateAccountBalance').disable(); |
|
|
this.activityForm.get('updateAccountBalance')?.disable(); |
|
|
this.activityForm.get('updateAccountBalance').setValue(false); |
|
|
this.activityForm.get('updateAccountBalance')?.setValue(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -284,7 +276,7 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
|
|
|
|
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('assetClass') |
|
|
.get('assetClass') |
|
|
.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((assetClass) => { |
|
|
.subscribe((assetClass) => { |
|
|
const assetSubClasses = ASSET_CLASS_MAPPING.get(assetClass) ?? []; |
|
|
const assetSubClasses = ASSET_CLASS_MAPPING.get(assetClass) ?? []; |
|
|
|
|
|
|
|
|
@ -297,28 +289,28 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
}) |
|
|
}) |
|
|
.sort((a, b) => a.label.localeCompare(b.label)); |
|
|
.sort((a, b) => a.label.localeCompare(b.label)); |
|
|
|
|
|
|
|
|
this.activityForm.get('assetSubClass').setValue(null); |
|
|
this.activityForm.get('assetSubClass')?.setValue(null); |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.activityForm.get('date').valueChanges.subscribe(() => { |
|
|
this.activityForm.get('date')?.valueChanges.subscribe(() => { |
|
|
if (isToday(this.activityForm.get('date').value)) { |
|
|
if (isToday(this.activityForm.get('date')?.value)) { |
|
|
this.activityForm.get('updateAccountBalance').enable(); |
|
|
this.activityForm.get('updateAccountBalance')?.enable(); |
|
|
} else { |
|
|
} else { |
|
|
this.activityForm.get('updateAccountBalance').disable(); |
|
|
this.activityForm.get('updateAccountBalance')?.disable(); |
|
|
this.activityForm.get('updateAccountBalance').setValue(false); |
|
|
this.activityForm.get('updateAccountBalance')?.setValue(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.activityForm.get('searchSymbol').valueChanges.subscribe(() => { |
|
|
this.activityForm.get('searchSymbol')?.valueChanges.subscribe(() => { |
|
|
if (this.activityForm.get('searchSymbol').invalid) { |
|
|
if (this.activityForm.get('searchSymbol')?.invalid) { |
|
|
this.data.activity.SymbolProfile = null; |
|
|
this.data.activity.SymbolProfile = null; |
|
|
} else if ( |
|
|
} else if ( |
|
|
['BUY', 'DIVIDEND', 'SELL'].includes( |
|
|
['BUY', 'DIVIDEND', 'SELL'].includes( |
|
|
this.activityForm.get('type').value |
|
|
this.activityForm.get('type')?.value |
|
|
) |
|
|
) |
|
|
) { |
|
|
) { |
|
|
this.updateAssetProfile(); |
|
|
this.updateAssetProfile(); |
|
|
@ -327,7 +319,7 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.activityForm.get('tags').valueChanges.subscribe((tags: Tag[]) => { |
|
|
this.activityForm.get('tags')?.valueChanges.subscribe((tags: Tag[]) => { |
|
|
const newTag = tags.find(({ id }) => { |
|
|
const newTag = tags.find(({ id }) => { |
|
|
return id === undefined; |
|
|
return id === undefined; |
|
|
}); |
|
|
}); |
|
|
@ -337,7 +329,7 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
.postTag({ ...newTag, userId: this.data.user.id }) |
|
|
.postTag({ ...newTag, userId: this.data.user.id }) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((tag) => { |
|
|
.subscribe((tag) => { |
|
|
this.activityForm.get('tags').setValue( |
|
|
this.activityForm.get('tags')?.setValue( |
|
|
tags.map((currentTag) => { |
|
|
tags.map((currentTag) => { |
|
|
if (currentTag.id === undefined) { |
|
|
if (currentTag.id === undefined) { |
|
|
return tag; |
|
|
return tag; |
|
|
@ -357,106 +349,106 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
|
|
|
|
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('type') |
|
|
.get('type') |
|
|
.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((type: ActivityType) => { |
|
|
.subscribe((type: ActivityType) => { |
|
|
if ( |
|
|
if ( |
|
|
type === 'VALUABLE' || |
|
|
type === 'VALUABLE' || |
|
|
(this.activityForm.get('dataSource').value === 'MANUAL' && |
|
|
(this.activityForm.get('dataSource')?.value === 'MANUAL' && |
|
|
type === 'BUY') |
|
|
type === 'BUY') |
|
|
) { |
|
|
) { |
|
|
const currency = |
|
|
const currency = |
|
|
this.data.accounts.find(({ id }) => { |
|
|
this.data.accounts.find(({ id }) => { |
|
|
return id === this.activityForm.get('accountId').value; |
|
|
return id === this.activityForm.get('accountId')?.value; |
|
|
})?.currency ?? this.data.user.settings.baseCurrency; |
|
|
})?.currency ?? this.data.user.settings.baseCurrency; |
|
|
|
|
|
|
|
|
this.activityForm.get('currency').setValue(currency); |
|
|
this.activityForm.get('currency')?.setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice')?.setValue(currency); |
|
|
|
|
|
|
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('dataSource') |
|
|
.get('dataSource') |
|
|
.removeValidators(Validators.required); |
|
|
?.removeValidators(Validators.required); |
|
|
this.activityForm.get('dataSource').updateValueAndValidity(); |
|
|
this.activityForm.get('dataSource')?.updateValueAndValidity(); |
|
|
this.activityForm.get('fee').setValue(0); |
|
|
this.activityForm.get('fee')?.setValue(0); |
|
|
this.activityForm.get('name').setValidators(Validators.required); |
|
|
this.activityForm.get('name')?.setValidators(Validators.required); |
|
|
this.activityForm.get('name').updateValueAndValidity(); |
|
|
this.activityForm.get('name')?.updateValueAndValidity(); |
|
|
|
|
|
|
|
|
if (type === 'VALUABLE') { |
|
|
if (type === 'VALUABLE') { |
|
|
this.activityForm.get('quantity').setValue(1); |
|
|
this.activityForm.get('quantity')?.setValue(1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('searchSymbol') |
|
|
.get('searchSymbol') |
|
|
.removeValidators(Validators.required); |
|
|
?.removeValidators(Validators.required); |
|
|
this.activityForm.get('searchSymbol').updateValueAndValidity(); |
|
|
this.activityForm.get('searchSymbol')?.updateValueAndValidity(); |
|
|
this.activityForm.get('updateAccountBalance').disable(); |
|
|
this.activityForm.get('updateAccountBalance')?.disable(); |
|
|
this.activityForm.get('updateAccountBalance').setValue(false); |
|
|
this.activityForm.get('updateAccountBalance')?.setValue(false); |
|
|
} else if (['FEE', 'INTEREST', 'LIABILITY'].includes(type)) { |
|
|
} else if (['FEE', 'INTEREST', 'LIABILITY'].includes(type)) { |
|
|
const currency = |
|
|
const currency = |
|
|
this.data.accounts.find(({ id }) => { |
|
|
this.data.accounts.find(({ id }) => { |
|
|
return id === this.activityForm.get('accountId').value; |
|
|
return id === this.activityForm.get('accountId')?.value; |
|
|
})?.currency ?? this.data.user.settings.baseCurrency; |
|
|
})?.currency ?? this.data.user.settings.baseCurrency; |
|
|
|
|
|
|
|
|
this.activityForm.get('currency').setValue(currency); |
|
|
this.activityForm.get('currency')?.setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice')?.setValue(currency); |
|
|
|
|
|
|
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('dataSource') |
|
|
.get('dataSource') |
|
|
.removeValidators(Validators.required); |
|
|
?.removeValidators(Validators.required); |
|
|
this.activityForm.get('dataSource').updateValueAndValidity(); |
|
|
this.activityForm.get('dataSource')?.updateValueAndValidity(); |
|
|
|
|
|
|
|
|
if (['INTEREST', 'LIABILITY'].includes(type)) { |
|
|
if (['INTEREST', 'LIABILITY'].includes(type)) { |
|
|
this.activityForm.get('fee').setValue(0); |
|
|
this.activityForm.get('fee')?.setValue(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.activityForm.get('name').setValidators(Validators.required); |
|
|
this.activityForm.get('name')?.setValidators(Validators.required); |
|
|
this.activityForm.get('name').updateValueAndValidity(); |
|
|
this.activityForm.get('name')?.updateValueAndValidity(); |
|
|
|
|
|
|
|
|
if (type === 'FEE') { |
|
|
if (type === 'FEE') { |
|
|
this.activityForm.get('quantity').setValue(0); |
|
|
this.activityForm.get('quantity')?.setValue(0); |
|
|
} else if (['INTEREST', 'LIABILITY'].includes(type)) { |
|
|
} else if (['INTEREST', 'LIABILITY'].includes(type)) { |
|
|
this.activityForm.get('quantity').setValue(1); |
|
|
this.activityForm.get('quantity')?.setValue(1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('searchSymbol') |
|
|
.get('searchSymbol') |
|
|
.removeValidators(Validators.required); |
|
|
?.removeValidators(Validators.required); |
|
|
this.activityForm.get('searchSymbol').updateValueAndValidity(); |
|
|
this.activityForm.get('searchSymbol')?.updateValueAndValidity(); |
|
|
|
|
|
|
|
|
if (type === 'FEE') { |
|
|
if (type === 'FEE') { |
|
|
this.activityForm.get('unitPrice').setValue(0); |
|
|
this.activityForm.get('unitPrice')?.setValue(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|
['FEE', 'INTEREST'].includes(type) && |
|
|
['FEE', 'INTEREST'].includes(type) && |
|
|
this.activityForm.get('accountId').value |
|
|
this.activityForm.get('accountId')?.value |
|
|
) { |
|
|
) { |
|
|
this.activityForm.get('updateAccountBalance').enable(); |
|
|
this.activityForm.get('updateAccountBalance')?.enable(); |
|
|
} else { |
|
|
} else { |
|
|
this.activityForm.get('updateAccountBalance').disable(); |
|
|
this.activityForm.get('updateAccountBalance')?.disable(); |
|
|
this.activityForm.get('updateAccountBalance').setValue(false); |
|
|
this.activityForm.get('updateAccountBalance')?.setValue(false); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('dataSource') |
|
|
.get('dataSource') |
|
|
.setValidators(Validators.required); |
|
|
?.setValidators(Validators.required); |
|
|
this.activityForm.get('dataSource').updateValueAndValidity(); |
|
|
this.activityForm.get('dataSource')?.updateValueAndValidity(); |
|
|
this.activityForm.get('name').removeValidators(Validators.required); |
|
|
this.activityForm.get('name')?.removeValidators(Validators.required); |
|
|
this.activityForm.get('name').updateValueAndValidity(); |
|
|
this.activityForm.get('name')?.updateValueAndValidity(); |
|
|
this.activityForm |
|
|
this.activityForm |
|
|
.get('searchSymbol') |
|
|
.get('searchSymbol') |
|
|
.setValidators(Validators.required); |
|
|
?.setValidators(Validators.required); |
|
|
this.activityForm.get('searchSymbol').updateValueAndValidity(); |
|
|
this.activityForm.get('searchSymbol')?.updateValueAndValidity(); |
|
|
this.activityForm.get('updateAccountBalance').enable(); |
|
|
this.activityForm.get('updateAccountBalance')?.enable(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.activityForm.get('type').setValue(this.data.activity?.type); |
|
|
this.activityForm.get('type')?.setValue(this.data.activity?.type); |
|
|
|
|
|
|
|
|
if (this.data.activity?.id) { |
|
|
if (this.data.activity?.id) { |
|
|
this.activityForm.get('searchSymbol').disable(); |
|
|
this.activityForm.get('searchSymbol')?.disable(); |
|
|
this.activityForm.get('type').disable(); |
|
|
this.activityForm.get('type')?.disable(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (this.data.activity?.SymbolProfile?.symbol) { |
|
|
if (this.data.activity?.SymbolProfile?.symbol) { |
|
|
@ -476,7 +468,7 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
|
|
|
|
|
|
public applyCurrentMarketPrice() { |
|
|
public applyCurrentMarketPrice() { |
|
|
this.activityForm.patchValue({ |
|
|
this.activityForm.patchValue({ |
|
|
currencyOfUnitPrice: this.activityForm.get('currency').value, |
|
|
currencyOfUnitPrice: this.activityForm.get('currency')?.value, |
|
|
unitPrice: this.currentMarketPrice |
|
|
unitPrice: this.currentMarketPrice |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@ -495,42 +487,42 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
|
|
|
|
|
|
public async onSubmit() { |
|
|
public async onSubmit() { |
|
|
const activity: CreateOrderDto | UpdateOrderDto = { |
|
|
const activity: CreateOrderDto | UpdateOrderDto = { |
|
|
accountId: this.activityForm.get('accountId').value, |
|
|
accountId: this.activityForm.get('accountId')?.value, |
|
|
assetClass: this.activityForm.get('assetClass').value, |
|
|
assetClass: this.activityForm.get('assetClass')?.value, |
|
|
assetSubClass: this.activityForm.get('assetSubClass').value, |
|
|
assetSubClass: this.activityForm.get('assetSubClass')?.value, |
|
|
comment: this.activityForm.get('comment').value || null, |
|
|
comment: this.activityForm.get('comment')?.value || null, |
|
|
currency: this.activityForm.get('currency').value, |
|
|
currency: this.activityForm.get('currency')?.value, |
|
|
customCurrency: this.activityForm.get('currencyOfUnitPrice').value, |
|
|
customCurrency: this.activityForm.get('currencyOfUnitPrice')?.value, |
|
|
dataSource: ['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes( |
|
|
dataSource: ['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes( |
|
|
this.activityForm.get('type').value |
|
|
this.activityForm.get('type')?.value |
|
|
) |
|
|
) |
|
|
? 'MANUAL' |
|
|
? 'MANUAL' |
|
|
: this.activityForm.get('dataSource').value, |
|
|
: this.activityForm.get('dataSource')?.value, |
|
|
date: this.activityForm.get('date').value, |
|
|
date: this.activityForm.get('date')?.value, |
|
|
fee: this.activityForm.get('fee').value, |
|
|
fee: this.activityForm.get('fee')?.value, |
|
|
quantity: this.activityForm.get('quantity').value, |
|
|
quantity: this.activityForm.get('quantity')?.value, |
|
|
symbol: |
|
|
symbol: |
|
|
(['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes( |
|
|
(['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes( |
|
|
this.activityForm.get('type').value |
|
|
this.activityForm.get('type')?.value |
|
|
) |
|
|
) |
|
|
? undefined |
|
|
? undefined |
|
|
: this.activityForm.get('searchSymbol')?.value?.symbol) ?? |
|
|
: this.activityForm.get('searchSymbol')?.value?.symbol) ?? |
|
|
this.activityForm.get('name')?.value, |
|
|
this.activityForm.get('name')?.value, |
|
|
tags: this.activityForm.get('tags').value?.map(({ id }) => { |
|
|
tags: this.activityForm.get('tags')?.value?.map(({ id }) => { |
|
|
return id; |
|
|
return id; |
|
|
}), |
|
|
}), |
|
|
type: |
|
|
type: |
|
|
this.activityForm.get('type').value === 'VALUABLE' |
|
|
this.activityForm.get('type')?.value === 'VALUABLE' |
|
|
? 'BUY' |
|
|
? 'BUY' |
|
|
: this.activityForm.get('type').value, |
|
|
: this.activityForm.get('type')?.value, |
|
|
unitPrice: this.activityForm.get('unitPrice').value |
|
|
unitPrice: this.activityForm.get('unitPrice')?.value |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
if (this.mode === 'create') { |
|
|
if (this.mode === 'create') { |
|
|
activity.updateAccountBalance = this.activityForm.get( |
|
|
activity.updateAccountBalance = this.activityForm.get( |
|
|
'updateAccountBalance' |
|
|
'updateAccountBalance' |
|
|
).value; |
|
|
)?.value; |
|
|
|
|
|
|
|
|
await validateObjectForForm({ |
|
|
await validateObjectForForm({ |
|
|
classDto: CreateOrderDto, |
|
|
classDto: CreateOrderDto, |
|
|
@ -563,8 +555,8 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
|
|
|
|
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchSymbolItem({ |
|
|
.fetchSymbolItem({ |
|
|
dataSource: this.activityForm.get('searchSymbol').value.dataSource, |
|
|
dataSource: this.activityForm.get('searchSymbol')?.value.dataSource, |
|
|
symbol: this.activityForm.get('searchSymbol').value.symbol |
|
|
symbol: this.activityForm.get('searchSymbol')?.value.symbol |
|
|
}) |
|
|
}) |
|
|
.pipe( |
|
|
.pipe( |
|
|
catchError(() => { |
|
|
catchError(() => { |
|
|
@ -580,9 +572,9 @@ export class GfCreateOrUpdateActivityDialogComponent { |
|
|
) |
|
|
) |
|
|
.subscribe(({ currency, dataSource, marketPrice }) => { |
|
|
.subscribe(({ currency, dataSource, marketPrice }) => { |
|
|
if (this.mode === 'create') { |
|
|
if (this.mode === 'create') { |
|
|
this.activityForm.get('currency').setValue(currency); |
|
|
this.activityForm.get('currency')?.setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency); |
|
|
this.activityForm.get('currencyOfUnitPrice')?.setValue(currency); |
|
|
this.activityForm.get('dataSource').setValue(dataSource); |
|
|
this.activityForm.get('dataSource')?.setValue(dataSource); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.currencyOfAssetProfile = currency; |
|
|
this.currencyOfAssetProfile = currency; |
|
|
|