|
|
|
@ -148,13 +148,14 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
.subscribe(async () => {
|
|
|
|
|
let exchangeRateOfUnitPrice = 1;
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].setErrors(null);
|
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].setErrors(null);
|
|
|
|
|
this.activityForm.get('feeInCustomCurrency').setErrors(null);
|
|
|
|
|
this.activityForm.get('unitPriceInCustomCurrency').setErrors(null);
|
|
|
|
|
|
|
|
|
|
const currency = this.activityForm.controls['currency'].value;
|
|
|
|
|
const currencyOfUnitPrice =
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].value;
|
|
|
|
|
const date = this.activityForm.controls['date'].value;
|
|
|
|
|
const currency = this.activityForm.get('currency').value;
|
|
|
|
|
const currencyOfUnitPrice = this.activityForm.get(
|
|
|
|
|
'currencyOfUnitPrice'
|
|
|
|
|
).value;
|
|
|
|
|
const date = this.activityForm.get('date').value;
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
currency &&
|
|
|
|
@ -174,104 +175,97 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
exchangeRateOfUnitPrice = marketPrice;
|
|
|
|
|
} catch {
|
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].setErrors({
|
|
|
|
|
this.activityForm.get('unitPriceInCustomCurrency').setErrors({
|
|
|
|
|
invalid: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const feeInCustomCurrency =
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].value *
|
|
|
|
|
this.activityForm.get('feeInCustomCurrency').value *
|
|
|
|
|
exchangeRateOfUnitPrice;
|
|
|
|
|
|
|
|
|
|
const unitPriceInCustomCurrency =
|
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].value *
|
|
|
|
|
this.activityForm.get('unitPriceInCustomCurrency').value *
|
|
|
|
|
exchangeRateOfUnitPrice;
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['fee'].setValue(feeInCustomCurrency, {
|
|
|
|
|
this.activityForm.get('fee').setValue(feeInCustomCurrency, {
|
|
|
|
|
emitEvent: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['unitPrice'].setValue(
|
|
|
|
|
unitPriceInCustomCurrency,
|
|
|
|
|
{
|
|
|
|
|
emitEvent: false
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.get('unitPrice').setValue(unitPriceInCustomCurrency, {
|
|
|
|
|
emitEvent: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
this.activityForm.controls['type'].value === 'BUY' ||
|
|
|
|
|
this.activityForm.controls['type'].value === 'FEE' ||
|
|
|
|
|
this.activityForm.controls['type'].value === 'ITEM'
|
|
|
|
|
this.activityForm.get('type').value === 'BUY' ||
|
|
|
|
|
this.activityForm.get('type').value === 'FEE' ||
|
|
|
|
|
this.activityForm.get('type').value === 'ITEM'
|
|
|
|
|
) {
|
|
|
|
|
this.total =
|
|
|
|
|
this.activityForm.controls['quantity'].value *
|
|
|
|
|
this.activityForm.controls['unitPrice'].value +
|
|
|
|
|
this.activityForm.controls['fee'].value ?? 0;
|
|
|
|
|
this.activityForm.get('quantity').value *
|
|
|
|
|
this.activityForm.get('unitPrice').value +
|
|
|
|
|
this.activityForm.get('fee').value ?? 0;
|
|
|
|
|
} else {
|
|
|
|
|
this.total =
|
|
|
|
|
this.activityForm.controls['quantity'].value *
|
|
|
|
|
this.activityForm.controls['unitPrice'].value -
|
|
|
|
|
this.activityForm.controls['fee'].value ?? 0;
|
|
|
|
|
this.activityForm.get('quantity').value *
|
|
|
|
|
this.activityForm.get('unitPrice').value -
|
|
|
|
|
this.activityForm.get('fee').value ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['accountId'].valueChanges.subscribe(
|
|
|
|
|
(accountId) => {
|
|
|
|
|
const type = this.activityForm.controls['type'].value;
|
|
|
|
|
this.activityForm.get('accountId').valueChanges.subscribe((accountId) => {
|
|
|
|
|
const type = this.activityForm.get('type').value;
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
type === 'FEE' ||
|
|
|
|
|
type === 'INTEREST' ||
|
|
|
|
|
type === 'ITEM' ||
|
|
|
|
|
type === 'LIABILITY'
|
|
|
|
|
) {
|
|
|
|
|
const currency =
|
|
|
|
|
this.data.accounts.find(({ id }) => {
|
|
|
|
|
return id === accountId;
|
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
|
if (
|
|
|
|
|
type === 'FEE' ||
|
|
|
|
|
type === 'INTEREST' ||
|
|
|
|
|
type === 'ITEM' ||
|
|
|
|
|
type === 'LIABILITY'
|
|
|
|
|
) {
|
|
|
|
|
const currency =
|
|
|
|
|
this.data.accounts.find(({ id }) => {
|
|
|
|
|
return id === accountId;
|
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
|
|
|
|
|
|
if (['FEE', 'INTEREST'].includes(type)) {
|
|
|
|
|
if (this.activityForm.controls['accountId'].value) {
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].enable();
|
|
|
|
|
} else {
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].disable();
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].setValue(
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
this.activityForm.get('currency').setValue(currency);
|
|
|
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency);
|
|
|
|
|
|
|
|
|
|
if (['FEE', 'INTEREST'].includes(type)) {
|
|
|
|
|
if (this.activityForm.get('accountId').value) {
|
|
|
|
|
this.activityForm.get('updateAccountBalance').enable();
|
|
|
|
|
} else {
|
|
|
|
|
this.activityForm.get('updateAccountBalance').disable();
|
|
|
|
|
this.activityForm.get('updateAccountBalance').setValue(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['date'].valueChanges.subscribe(() => {
|
|
|
|
|
if (isToday(this.activityForm.controls['date'].value)) {
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].enable();
|
|
|
|
|
this.activityForm.get('date').valueChanges.subscribe(() => {
|
|
|
|
|
if (isToday(this.activityForm.get('date').value)) {
|
|
|
|
|
this.activityForm.get('updateAccountBalance').enable();
|
|
|
|
|
} else {
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].disable();
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].setValue(false);
|
|
|
|
|
this.activityForm.get('updateAccountBalance').disable();
|
|
|
|
|
this.activityForm.get('updateAccountBalance').setValue(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['searchSymbol'].valueChanges.subscribe(() => {
|
|
|
|
|
if (this.activityForm.controls['searchSymbol'].invalid) {
|
|
|
|
|
this.activityForm.get('searchSymbol').valueChanges.subscribe(() => {
|
|
|
|
|
if (this.activityForm.get('searchSymbol').invalid) {
|
|
|
|
|
this.data.activity.SymbolProfile = null;
|
|
|
|
|
} else if (
|
|
|
|
|
['BUY', 'DIVIDEND', 'SELL'].includes(
|
|
|
|
|
this.activityForm.controls['type'].value
|
|
|
|
|
this.activityForm.get('type').value
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
this.activityForm.controls['dataSource'].setValue(
|
|
|
|
|
this.activityForm.controls['searchSymbol'].value.dataSource
|
|
|
|
|
);
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('dataSource')
|
|
|
|
|
.setValue(this.activityForm.get('searchSymbol').value.dataSource);
|
|
|
|
|
|
|
|
|
|
this.updateSymbol();
|
|
|
|
|
}
|
|
|
|
@ -282,130 +276,127 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
this.filteredTagsObservable = this.activityForm.controls[
|
|
|
|
|
'tags'
|
|
|
|
|
].valueChanges.pipe(
|
|
|
|
|
startWith(this.activityForm.controls['tags'].value),
|
|
|
|
|
startWith(this.activityForm.get('tags').value),
|
|
|
|
|
map((aTags: Tag[] | null) => {
|
|
|
|
|
return aTags ? this.filterTags(aTags) : this.tags.slice();
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['type'].valueChanges
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('type')
|
|
|
|
|
.valueChanges.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
|
.subscribe((type: Type) => {
|
|
|
|
|
if (type === 'ITEM') {
|
|
|
|
|
this.activityForm.controls['accountId'].removeValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['accountId'].updateValueAndValidity();
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('accountId')
|
|
|
|
|
.removeValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('accountId').updateValueAndValidity();
|
|
|
|
|
|
|
|
|
|
const currency =
|
|
|
|
|
this.data.accounts.find(({ id }) => {
|
|
|
|
|
return id === this.activityForm.controls['accountId'].value;
|
|
|
|
|
return id === this.activityForm.get('accountId').value;
|
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['dataSource'].removeValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['dataSource'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].reset();
|
|
|
|
|
this.activityForm.controls['name'].setValidators(Validators.required);
|
|
|
|
|
this.activityForm.controls['name'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.controls['quantity'].setValue(1);
|
|
|
|
|
this.activityForm.controls['searchSymbol'].removeValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['searchSymbol'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].disable();
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].setValue(false);
|
|
|
|
|
this.activityForm.get('currency').setValue(currency);
|
|
|
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency);
|
|
|
|
|
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('dataSource')
|
|
|
|
|
.removeValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('dataSource').updateValueAndValidity();
|
|
|
|
|
this.activityForm.get('feeInCustomCurrency').reset();
|
|
|
|
|
this.activityForm.get('name').setValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('name').updateValueAndValidity();
|
|
|
|
|
this.activityForm.get('quantity').setValue(1);
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('searchSymbol')
|
|
|
|
|
.removeValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('searchSymbol').updateValueAndValidity();
|
|
|
|
|
this.activityForm.get('updateAccountBalance').disable();
|
|
|
|
|
this.activityForm.get('updateAccountBalance').setValue(false);
|
|
|
|
|
} else if (
|
|
|
|
|
type === 'FEE' ||
|
|
|
|
|
type === 'INTEREST' ||
|
|
|
|
|
type === 'LIABILITY'
|
|
|
|
|
) {
|
|
|
|
|
this.activityForm.controls['accountId'].removeValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['accountId'].updateValueAndValidity();
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('accountId')
|
|
|
|
|
.removeValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('accountId').updateValueAndValidity();
|
|
|
|
|
|
|
|
|
|
const currency =
|
|
|
|
|
this.data.accounts.find(({ id }) => {
|
|
|
|
|
return id === this.activityForm.controls['accountId'].value;
|
|
|
|
|
return id === this.activityForm.get('accountId').value;
|
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
|
this.activityForm.get('currency').setValue(currency);
|
|
|
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency);
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['dataSource'].removeValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['dataSource'].updateValueAndValidity();
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('dataSource')
|
|
|
|
|
.removeValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('dataSource').updateValueAndValidity();
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
(type === 'FEE' &&
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].value === 0) ||
|
|
|
|
|
this.activityForm.get('feeInCustomCurrency').value === 0) ||
|
|
|
|
|
type === 'INTEREST' ||
|
|
|
|
|
type === 'LIABILITY'
|
|
|
|
|
) {
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].reset();
|
|
|
|
|
this.activityForm.get('feeInCustomCurrency').reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['name'].setValidators(Validators.required);
|
|
|
|
|
this.activityForm.controls['name'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.get('name').setValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('name').updateValueAndValidity();
|
|
|
|
|
|
|
|
|
|
if (type === 'FEE') {
|
|
|
|
|
this.activityForm.controls['quantity'].setValue(0);
|
|
|
|
|
this.activityForm.get('quantity').setValue(0);
|
|
|
|
|
} else if (type === 'INTEREST' || type === 'LIABILITY') {
|
|
|
|
|
this.activityForm.controls['quantity'].setValue(1);
|
|
|
|
|
this.activityForm.get('quantity').setValue(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['searchSymbol'].removeValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['searchSymbol'].updateValueAndValidity();
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('searchSymbol')
|
|
|
|
|
.removeValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('searchSymbol').updateValueAndValidity();
|
|
|
|
|
|
|
|
|
|
if (type === 'FEE') {
|
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].setValue(0);
|
|
|
|
|
this.activityForm.get('unitPriceInCustomCurrency').setValue(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
['FEE', 'INTEREST'].includes(type) &&
|
|
|
|
|
this.activityForm.controls['accountId'].value
|
|
|
|
|
this.activityForm.get('accountId').value
|
|
|
|
|
) {
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].enable();
|
|
|
|
|
this.activityForm.get('updateAccountBalance').enable();
|
|
|
|
|
} else {
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].disable();
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].setValue(false);
|
|
|
|
|
this.activityForm.get('updateAccountBalance').disable();
|
|
|
|
|
this.activityForm.get('updateAccountBalance').setValue(false);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.activityForm.controls['accountId'].setValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['accountId'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.controls['dataSource'].setValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['dataSource'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.controls['name'].removeValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['name'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.controls['searchSymbol'].setValidators(
|
|
|
|
|
Validators.required
|
|
|
|
|
);
|
|
|
|
|
this.activityForm.controls['searchSymbol'].updateValueAndValidity();
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].enable();
|
|
|
|
|
this.activityForm.get('accountId').setValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('accountId').updateValueAndValidity();
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('dataSource')
|
|
|
|
|
.setValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('dataSource').updateValueAndValidity();
|
|
|
|
|
this.activityForm.get('name').removeValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('name').updateValueAndValidity();
|
|
|
|
|
this.activityForm
|
|
|
|
|
.get('searchSymbol')
|
|
|
|
|
.setValidators(Validators.required);
|
|
|
|
|
this.activityForm.get('searchSymbol').updateValueAndValidity();
|
|
|
|
|
this.activityForm.get('updateAccountBalance').enable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['type'].setValue(this.data.activity?.type);
|
|
|
|
|
this.activityForm.get('type').setValue(this.data.activity?.type);
|
|
|
|
|
|
|
|
|
|
if (this.data.activity?.id) {
|
|
|
|
|
this.activityForm.controls['searchSymbol'].disable();
|
|
|
|
|
this.activityForm.controls['type'].disable();
|
|
|
|
|
this.activityForm.get('searchSymbol').disable();
|
|
|
|
|
this.activityForm.get('type').disable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.data.activity?.SymbolProfile?.symbol) {
|
|
|
|
@ -425,14 +416,14 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
public applyCurrentMarketPrice() {
|
|
|
|
|
this.activityForm.patchValue({
|
|
|
|
|
currencyOfUnitPrice: this.activityForm.controls['currency'].value,
|
|
|
|
|
currencyOfUnitPrice: this.activityForm.get('currency').value,
|
|
|
|
|
unitPriceInCustomCurrency: this.currentMarketPrice
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onAddTag(event: MatAutocompleteSelectedEvent) {
|
|
|
|
|
this.activityForm.controls['tags'].setValue([
|
|
|
|
|
...(this.activityForm.controls['tags'].value ?? []),
|
|
|
|
|
this.activityForm.get('tags').setValue([
|
|
|
|
|
...(this.activityForm.get('tags').value ?? []),
|
|
|
|
|
this.tags.find(({ id }) => {
|
|
|
|
|
return id === event.option.value;
|
|
|
|
|
})
|
|
|
|
@ -445,8 +436,8 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onRemoveTag(aTag: Tag) {
|
|
|
|
|
this.activityForm.controls['tags'].setValue(
|
|
|
|
|
this.activityForm.controls['tags'].value.filter(({ id }) => {
|
|
|
|
|
this.activityForm.get('tags').setValue(
|
|
|
|
|
this.activityForm.get('tags').value.filter(({ id }) => {
|
|
|
|
|
return id !== aTag.id;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
@ -454,25 +445,24 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
public async onSubmit() {
|
|
|
|
|
const activity: CreateOrderDto | UpdateOrderDto = {
|
|
|
|
|
accountId: this.activityForm.controls['accountId'].value,
|
|
|
|
|
assetClass: this.activityForm.controls['assetClass'].value,
|
|
|
|
|
assetSubClass: this.activityForm.controls['assetSubClass'].value,
|
|
|
|
|
comment: this.activityForm.controls['comment'].value,
|
|
|
|
|
currency: this.activityForm.controls['currency'].value,
|
|
|
|
|
customCurrency: this.activityForm.controls['currencyOfUnitPrice'].value,
|
|
|
|
|
date: this.activityForm.controls['date'].value,
|
|
|
|
|
dataSource: this.activityForm.controls['dataSource'].value,
|
|
|
|
|
fee: this.activityForm.controls['fee'].value,
|
|
|
|
|
quantity: this.activityForm.controls['quantity'].value,
|
|
|
|
|
accountId: this.activityForm.get('accountId').value,
|
|
|
|
|
assetClass: this.activityForm.get('assetClass').value,
|
|
|
|
|
assetSubClass: this.activityForm.get('assetSubClass').value,
|
|
|
|
|
comment: this.activityForm.get('comment').value,
|
|
|
|
|
currency: this.activityForm.get('currency').value,
|
|
|
|
|
customCurrency: this.activityForm.get('currencyOfUnitPrice').value,
|
|
|
|
|
date: this.activityForm.get('date').value,
|
|
|
|
|
dataSource: this.activityForm.get('dataSource').value,
|
|
|
|
|
fee: this.activityForm.get('fee').value,
|
|
|
|
|
quantity: this.activityForm.get('quantity').value,
|
|
|
|
|
symbol:
|
|
|
|
|
this.activityForm.controls['searchSymbol'].value?.symbol ===
|
|
|
|
|
undefined ||
|
|
|
|
|
isUUID(this.activityForm.controls['searchSymbol'].value?.symbol)
|
|
|
|
|
? this.activityForm.controls['name'].value
|
|
|
|
|
: this.activityForm.controls['searchSymbol'].value.symbol,
|
|
|
|
|
tags: this.activityForm.controls['tags'].value,
|
|
|
|
|
type: this.activityForm.controls['type'].value,
|
|
|
|
|
unitPrice: this.activityForm.controls['unitPrice'].value
|
|
|
|
|
this.activityForm.get('searchSymbol').value?.symbol === undefined ||
|
|
|
|
|
isUUID(this.activityForm.get('searchSymbol').value?.symbol)
|
|
|
|
|
? this.activityForm.get('name').value
|
|
|
|
|
: this.activityForm.get('searchSymbol').value.symbol,
|
|
|
|
|
tags: this.activityForm.get('tags').value,
|
|
|
|
|
type: this.activityForm.get('type').value,
|
|
|
|
|
unitPrice: this.activityForm.get('unitPrice').value
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
@ -487,7 +477,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
(activity as CreateOrderDto).updateAccountBalance =
|
|
|
|
|
this.activityForm.controls['updateAccountBalance'].value;
|
|
|
|
|
this.activityForm.get('updateAccountBalance').value;
|
|
|
|
|
|
|
|
|
|
await validateObjectForForm({
|
|
|
|
|
classDto: CreateOrderDto,
|
|
|
|
@ -524,8 +514,8 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
this.dataService
|
|
|
|
|
.fetchSymbolItem({
|
|
|
|
|
dataSource: this.activityForm.controls['dataSource'].value,
|
|
|
|
|
symbol: this.activityForm.controls['searchSymbol'].value.symbol
|
|
|
|
|
dataSource: this.activityForm.get('dataSource').value,
|
|
|
|
|
symbol: this.activityForm.get('searchSymbol').value.symbol
|
|
|
|
|
})
|
|
|
|
|
.pipe(
|
|
|
|
|
catchError(() => {
|
|
|
|
@ -540,9 +530,9 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
|
takeUntil(this.unsubscribeSubject)
|
|
|
|
|
)
|
|
|
|
|
.subscribe(({ currency, dataSource, marketPrice }) => {
|
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
|
this.activityForm.controls['dataSource'].setValue(dataSource);
|
|
|
|
|
this.activityForm.get('currency').setValue(currency);
|
|
|
|
|
this.activityForm.get('currencyOfUnitPrice').setValue(currency);
|
|
|
|
|
this.activityForm.get('dataSource').setValue(dataSource);
|
|
|
|
|
|
|
|
|
|
this.currentMarketPrice = marketPrice;
|
|
|
|
|
|
|
|
|
|