Fix/holdings always include cash position (#1897)
* Improved holdings table showing cash position also when the filter contains accounts * Update changelog
This commit is contained in:
parent
0464adccce
commit
672d8dfab2
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Improved the holdings table by showing the cash position also when the filter contains the accounts, so that we can see the total allocation for that account
|
||||||
|
|
||||||
## 1.261.0 - 2023-04-25
|
## 1.261.0 - 2023-04-25
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -462,10 +462,17 @@ export class PortfolioService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const holdings: PortfolioDetails['holdings'] = {};
|
const holdings: PortfolioDetails['holdings'] = {};
|
||||||
const totalInvestmentInBaseCurrency = currentPositions.totalInvestment.plus(
|
const totalValueInBaseCurrency = currentPositions.currentValue.plus(
|
||||||
cashDetails.balanceInBaseCurrency
|
cashDetails.balanceInBaseCurrency
|
||||||
);
|
);
|
||||||
let filteredValueInBaseCurrency = currentPositions.currentValue;
|
|
||||||
|
const isFilteredByAccount = filters.some((filter) => {
|
||||||
|
return filter.type === 'ACCOUNT';
|
||||||
|
});
|
||||||
|
|
||||||
|
let filteredValueInBaseCurrency = isFilteredByAccount
|
||||||
|
? totalValueInBaseCurrency
|
||||||
|
: currentPositions.currentValue;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
filters?.length === 0 ||
|
filters?.length === 0 ||
|
||||||
@ -564,12 +571,11 @@ export class PortfolioService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const isFilteredByCash = filters.some((filter) => {
|
||||||
filters?.length === 0 ||
|
return filter.type === 'ASSET_CLASS' && filter.id === 'CASH';
|
||||||
(filters?.length === 1 &&
|
});
|
||||||
filters[0].type === 'ASSET_CLASS' &&
|
|
||||||
filters[0].id === 'CASH')
|
if (filters.length === 0 || isFilteredByCash || isFilteredByAccount) {
|
||||||
) {
|
|
||||||
const cashPositions = await this.getCashPositions({
|
const cashPositions = await this.getCashPositions({
|
||||||
cashDetails,
|
cashDetails,
|
||||||
userCurrency,
|
userCurrency,
|
||||||
@ -595,7 +601,7 @@ export class PortfolioService {
|
|||||||
filters[0].id === EMERGENCY_FUND_TAG_ID &&
|
filters[0].id === EMERGENCY_FUND_TAG_ID &&
|
||||||
filters[0].type === 'TAG'
|
filters[0].type === 'TAG'
|
||||||
) {
|
) {
|
||||||
const cashPositions = await this.getCashPositions({
|
const emergencyFundCashPositions = await this.getCashPositions({
|
||||||
cashDetails,
|
cashDetails,
|
||||||
userCurrency,
|
userCurrency,
|
||||||
value: filteredValueInBaseCurrency
|
value: filteredValueInBaseCurrency
|
||||||
@ -620,7 +626,7 @@ export class PortfolioService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
holdings[userCurrency] = {
|
holdings[userCurrency] = {
|
||||||
...cashPositions[userCurrency],
|
...emergencyFundCashPositions[userCurrency],
|
||||||
investment: emergencyFundInCash,
|
investment: emergencyFundInCash,
|
||||||
value: emergencyFundInCash
|
value: emergencyFundInCash
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user