|
|
@ -98,10 +98,6 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
this.data.activity?.SymbolProfile?.currency,
|
|
|
|
this.data.activity?.SymbolProfile?.currency,
|
|
|
|
Validators.required
|
|
|
|
Validators.required
|
|
|
|
],
|
|
|
|
],
|
|
|
|
currencyOfFee: [
|
|
|
|
|
|
|
|
this.data.activity?.SymbolProfile?.currency,
|
|
|
|
|
|
|
|
Validators.required
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
currencyOfUnitPrice: [
|
|
|
|
currencyOfUnitPrice: [
|
|
|
|
this.data.activity?.SymbolProfile?.currency,
|
|
|
|
this.data.activity?.SymbolProfile?.currency,
|
|
|
|
Validators.required
|
|
|
|
Validators.required
|
|
|
@ -149,45 +145,16 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
takeUntil(this.unsubscribeSubject)
|
|
|
|
takeUntil(this.unsubscribeSubject)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.subscribe(async () => {
|
|
|
|
.subscribe(async () => {
|
|
|
|
let exchangeRateOfFee = 1;
|
|
|
|
|
|
|
|
let exchangeRateOfUnitPrice = 1;
|
|
|
|
let exchangeRateOfUnitPrice = 1;
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].setErrors(null);
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].setErrors(null);
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].setErrors(null);
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].setErrors(null);
|
|
|
|
|
|
|
|
|
|
|
|
const currency = this.activityForm.controls['currency'].value;
|
|
|
|
const currency = this.activityForm.controls['currency'].value;
|
|
|
|
const currencyOfFee = this.activityForm.controls['currencyOfFee'].value;
|
|
|
|
|
|
|
|
const currencyOfUnitPrice =
|
|
|
|
const currencyOfUnitPrice =
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].value;
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].value;
|
|
|
|
const date = this.activityForm.controls['date'].value;
|
|
|
|
const date = this.activityForm.controls['date'].value;
|
|
|
|
|
|
|
|
|
|
|
|
if (currency && currencyOfFee && currency !== currencyOfFee && date) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const { marketPrice } = await lastValueFrom(
|
|
|
|
|
|
|
|
this.dataService
|
|
|
|
|
|
|
|
.fetchExchangeRateForDate({
|
|
|
|
|
|
|
|
date,
|
|
|
|
|
|
|
|
symbol: `${currencyOfFee}-${currency}`
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject))
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exchangeRateOfFee = marketPrice;
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].setErrors({
|
|
|
|
|
|
|
|
invalid: true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const feeInCustomCurrency =
|
|
|
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].value *
|
|
|
|
|
|
|
|
exchangeRateOfFee;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['fee'].setValue(feeInCustomCurrency, {
|
|
|
|
|
|
|
|
emitEvent: false
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
currency &&
|
|
|
|
currency &&
|
|
|
|
currencyOfUnitPrice &&
|
|
|
|
currencyOfUnitPrice &&
|
|
|
@ -212,10 +179,18 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const feeInCustomCurrency =
|
|
|
|
|
|
|
|
this.activityForm.controls['feeInCustomCurrency'].value *
|
|
|
|
|
|
|
|
exchangeRateOfUnitPrice;
|
|
|
|
|
|
|
|
|
|
|
|
const unitPriceInCustomCurrency =
|
|
|
|
const unitPriceInCustomCurrency =
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].value *
|
|
|
|
this.activityForm.controls['unitPriceInCustomCurrency'].value *
|
|
|
|
exchangeRateOfUnitPrice;
|
|
|
|
exchangeRateOfUnitPrice;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['fee'].setValue(feeInCustomCurrency, {
|
|
|
|
|
|
|
|
emitEvent: false
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['unitPrice'].setValue(
|
|
|
|
this.activityForm.controls['unitPrice'].setValue(
|
|
|
|
unitPriceInCustomCurrency,
|
|
|
|
unitPriceInCustomCurrency,
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -258,7 +233,6 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfFee'].setValue(currency);
|
|
|
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
|
|
|
|
|
|
|
|
if (['FEE', 'INTEREST'].includes(type)) {
|
|
|
|
if (['FEE', 'INTEREST'].includes(type)) {
|
|
|
@ -328,7 +302,6 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfFee'].setValue(currency);
|
|
|
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['dataSource'].removeValidators(
|
|
|
|
this.activityForm.controls['dataSource'].removeValidators(
|
|
|
@ -361,7 +334,6 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
})?.currency ?? this.data.user.settings.baseCurrency;
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfFee'].setValue(currency);
|
|
|
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
|
|
|
|
|
|
|
|
this.activityForm.controls['dataSource'].removeValidators(
|
|
|
|
this.activityForm.controls['dataSource'].removeValidators(
|
|
|
@ -486,6 +458,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
assetSubClass: this.activityForm.controls['assetSubClass'].value,
|
|
|
|
assetSubClass: this.activityForm.controls['assetSubClass'].value,
|
|
|
|
comment: this.activityForm.controls['comment'].value,
|
|
|
|
comment: this.activityForm.controls['comment'].value,
|
|
|
|
currency: this.activityForm.controls['currency'].value,
|
|
|
|
currency: this.activityForm.controls['currency'].value,
|
|
|
|
|
|
|
|
customCurrency: this.activityForm.controls['currencyOfUnitPrice'].value,
|
|
|
|
date: this.activityForm.controls['date'].value,
|
|
|
|
date: this.activityForm.controls['date'].value,
|
|
|
|
dataSource: this.activityForm.controls['dataSource'].value,
|
|
|
|
dataSource: this.activityForm.controls['dataSource'].value,
|
|
|
|
fee: this.activityForm.controls['fee'].value,
|
|
|
|
fee: this.activityForm.controls['fee'].value,
|
|
|
@ -549,7 +522,6 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.subscribe(({ currency, dataSource, marketPrice }) => {
|
|
|
|
.subscribe(({ currency, dataSource, marketPrice }) => {
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currency'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfFee'].setValue(currency);
|
|
|
|
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
|
|
|
|
this.activityForm.controls['dataSource'].setValue(dataSource);
|
|
|
|
this.activityForm.controls['dataSource'].setValue(dataSource);
|
|
|
|
|
|
|
|
|
|
|
|