From fc91dd8ef4f2204571aef8ba609eeb12720c8a04 Mon Sep 17 00:00:00 2001 From: Charles Smith Date: Sun, 11 Jun 2023 19:37:24 -0400 Subject: [PATCH] added a switch to include dividends or not in the portfolio gain metric --- frontend/src/components/PositionCard.vue | 9 +++++---- frontend/src/views/Portfolio.vue | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/PositionCard.vue b/frontend/src/components/PositionCard.vue index 36adc45..3e721a9 100644 --- a/frontend/src/components/PositionCard.vue +++ b/frontend/src/components/PositionCard.vue @@ -4,7 +4,7 @@ import {useActivityStore} from "@/stores/ActivitiesStore"; export default { name: "PositionCard", - props: ['position', 'stock'], + props: ['position', 'stock', 'includeDivGains'], methods: { ...mapActions(useActivityStore, ['getActivities']), @@ -23,20 +23,21 @@ export default { }, getLifetimeDividends(stock) { return this.getActivities().reduce((a, activity) => { - console.log(stock, activity) if(activity.type !== 'dividend' || activity.symbol != stock.symbol) return a return a + activity.amount }, 0) }, getAbsoluteGain(position, stock) { - return (this.getCapitalGain(position) + this.getLifetimeDividends(stock)).toFixed(2) + if(this.includeDivGains) + return (this.getCapitalGain(position) + this.getLifetimeDividends(stock)).toFixed(2) + return this.getCapitalGain(position).toFixed(2) }, } } +
+ + + + +