Skip to content

Commit

Permalink
Add report to get annual revaluation (#380)
Browse files Browse the repository at this point in the history
* npm update. cypress_console ok

* Created report annual revaluation

* Improving UI

* Now annual revaluation filter by zero_risk investments
  • Loading branch information
turulomio authored May 17, 2024
1 parent b87db29 commit e421633
Show file tree
Hide file tree
Showing 8 changed files with 610 additions and 913 deletions.
17 changes: 17 additions & 0 deletions cypress/e2e/ReportsAnnualRevaluation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { login_test_User, add_investmentoperation_from_Home } from "./commons"

describe('e2e Annual revaluation Catalog', () => {
it('Annual revaluation', () => {
login_test_User(cy)

// Create investment operation
add_investmentoperation_from_Home(cy)
cy.getDataTest("InvestmentsView_ButtonClose").click()

//Open lateral menu
cy.getDataTest('LateralIcon').click()
cy.getDataTest('LateralReports').click()
cy.getDataTest('LateralReportsAnnualRevaluation').click()

})
})
1,377 changes: 480 additions & 897 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Money Money",
"version": "1.2.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand All @@ -21,31 +22,31 @@
"moment-timezone": "^0.5.45",
"pinia": "^2.1.7",
"roboto-fontface": "*",
"vue": "^3.4.25",
"vue": "^3.4.27",
"vue-i18n": "^9.13.1",
"vue-i18n-extract": "^2.0.7",
"vue-router": "^4.3.2",
"vuetify": "^3.5.17",
"vuetify": "^3.6.6",
"vuetify_rules": "^0.6.0",
"webfontloader": "^1.6.28"
},
"devDependencies": {
"@cypress/code-coverage": "^3.12.37",
"@cypress/code-coverage": "^3.12.39",
"@cypress/vite-dev-server": "^5.0.7",
"@eslint/js": "^9.1.1",
"@eslint/js": "^9.2.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vitest/coverage-v8": "^1.5.2",
"@vitest/ui": "^1.5.2",
"@vue/test-utils": "^2.4.5",
"cypress": "^13.8.1",
"eslint": "^9.1.1",
"eslint-plugin-vue": "^9.25.0",
"globals": "^15.0.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/ui": "^1.6.0",
"@vue/test-utils": "^2.4.6",
"cypress": "^13.9.0",
"eslint": "^9.2.0",
"eslint-plugin-vue": "^9.26.0",
"globals": "^15.2.0",
"npm-check-updates": "^16.14.20",
"vite": "^5.2.10",
"vite": "^5.2.11",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-istanbul": "^6.0.0",
"vite-plugin-istanbul": "^6.0.2",
"vite-plugin-vuetify": "^2.0.3",
"vitest": "^1.5.2"
"vitest": "^1.6.0"
}
}
3 changes: 3 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<v-list-item data-test="LateralReportsLastOperation" link router :to="{ name: 'reports_lastoperation'}">
<v-list-item-title>{{ $t("Investments last operation") }}</v-list-item-title>
</v-list-item>
<v-list-item data-test="LateralReportsAnnualRevaluation" link router :to="{ name: 'reports_annualrevaluation'}">
<v-list-item-title>{{ $t("Annual revaluation") }}</v-list-item-title>
</v-list-item>
<v-list-item data-test="LateralProductsRanges" link router :to="{ name: 'products_ranges'}">
<v-list-item-title>{{ $t("Product ranges") }}</v-list-item-title>
</v-list-item>
Expand Down
92 changes: 92 additions & 0 deletions src/components/ReportsAnnualRevaluation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<template>
<div class="pa-4">
<h1 class="mb-3">{{ $t("Investments operations annual revaluation report") }}</h1>
<v-checkbox v-model="only_zero" :label="$t('Show only investments operations from zero risk investments')" />
<v-data-table density="compact" :headers="headers" :items="list_io" class="elevation-1" :sort-by="[{key:'datetime',order:'asc'}]" fixed-header height="800" :loading="$attrs.loading" :items-per-page="10000" hide-default-footer :key="key">
<template #item.datetime="{item}">
<div>{{ localtime(item.datetime)}}</div>
</template>
<template #item.operationstypes="{item}">
<div>{{ getMapObjectById("operationstypes",item.operationstypes_id).localname }}</div>
</template>
<template #item.price_user="{item}">
<div class="text-right" v-html="localcurrency_html(item.price_user)"></div>
</template>
<template #item.balance_last_year_or_invested="{item}">
<div class="text-right" v-html="localcurrency_html(item.balance_last_year_or_invested)"></div>
</template>
<template #item.current_year_gains_user="{item}">
<div class="text-right" v-html="localcurrency_html(item.current_year_gains_user)"></div>
</template>
<template #item.percentage="{item}">
<div class="text-right" v-html="percentage_html(item.current_year_gains_user/item.invested_user)"></div>
</template>
<template #tbody>
<tr class="totalrow" v-if="list_io.length>0">
<td>{{ f($t("Total ([0] registers)"), [list_io.length])}}</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-right" v-html="localcurrency_html(listobjects_sum(list_io,'balance_last_year_or_invested'))"></td>
<td class="text-right" v-html="localcurrency_html(listobjects_sum(list_io,'current_year_gains_user'))"></td>
<td class="text-right" v-html="percentage_html(listobjects_sum(list_io,'current_year_gains_user')/listobjects_sum(list_io,'balance_last_year_or_invested'))"></td>
</tr>
</template>
</v-data-table>
</div>
</template>

<script>
import axios from 'axios'
import { useStore } from "@/store"
import { localtime,f } from 'vuetify_rules'
export default {
components:{
},
data(){
return{
list_io: [],
key: 0,
only_zero:false,
loading:false,
headers: [
{ title: this.$t('Date and time'), key: 'datetime',sortable: true },
{ title: this.$t('Investments'), key: 'name',sortable: true },
{ title: this.$t('Operation'), key: 'operationstypes',sortable: true },
{ title: this.$t('Shares'), key: 'shares',sortable: false, align:'end'},
{ title: this.$t('Price'), key: 'price_user',sortable: false, align:'end'},
{ title: this.$t('Balance last year or invested'), key: 'balance_last_year_or_invested',sortable: false, align:'end'},
{ title: this.$t('Annual gains'), key: 'current_year_gains_user',sortable: false, align:'end'},
{ title: this.$t('% Annual'), key: 'percentage',sortable: false, align:'end'},
],
}
},
watch:{
only_zero(){
this.refreshTable()
console.log("AHORA")
}
},
methods:{
useStore,
f,
localtime,
refreshTable(){
this.loading=true
var onlyzerostring=(this.only_zero)? "?only_zero=true": ""
return axios.get(`${this.useStore().apiroot}/reports/annual/revaluation/${onlyzerostring}`, this.myheaders())
.then((response) => {
this.list_io=response.data
this.loading=false
this.key+=1
}, (error) => {
this.parseResponseError(error)
});
}
},
mounted(){
this.refreshTable()
}
}
</script>
1 change: 1 addition & 0 deletions src/empty_objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export function empty_ios(){
mode:1,
currency: "EUR",
simulation:[], //Array of empty_ios_simulation_operation
addition_current_year_gains:false,
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ export function getOperationstypesForInvestmentsOperations() {
export function getMapObjectById(catalog,id) {
// If id doesn't exists return undefined
var url=hyperlinked_url(catalog,id)
console.log(catalog,id,url)
var r= useStore()[catalog].get(url)
console.log(r)
return r
}

Expand Down
2 changes: 2 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ReportsDividends from './components/ReportsDividends'
import ReportsEvolution from './components/ReportsEvolution'
import ReportsInvestmentsClasses from './components/ReportsInvestmentsClasses'
import ReportscurrentInvestmentsOperations from './components/ReportsCurrentInvestmentsOperations'
import ReportsAnnualRevaluation from './components/ReportsAnnualRevaluation.vue'
import ReportsInvestmentsLastOperation from './components/ReportsInvestmentsLastOperation'
import ReportsRanking from './components/ReportsRanking'
import ReportsZeroRisk from './components/ReportsZeroRisk.vue'
Expand Down Expand Up @@ -59,6 +60,7 @@ export const router = createRouter({
{ path: `${import.meta.env.BASE_URL}/reports/dividens/`, name: 'reports_dividends', component: ReportsDividends },
{ path: `${import.meta.env.BASE_URL}/reports/investmentsclasses/`, name: 'reports_investments_classes', component: ReportsInvestmentsClasses },
{ path: `${import.meta.env.BASE_URL}/reports/investments/lastoperation/`, name: 'reports_lastoperation', component: ReportsInvestmentsLastOperation },
{ path: `${import.meta.env.BASE_URL}/reports/annualrevaluation/`, name: 'reports_annualrevaluation', component: ReportsAnnualRevaluation },
{ path: `${import.meta.env.BASE_URL}/reports/investmentsoperations/current/`, name: 'reports_investmentsoperations_current', component: ReportscurrentInvestmentsOperations },
{ path: `${import.meta.env.BASE_URL}/reports/ranking/`, name: 'reports_ranking', component: ReportsRanking },
{ path: `${import.meta.env.BASE_URL}/reports/evolution/`, name: 'reports_evolution', component: ReportsEvolution },
Expand Down

0 comments on commit e421633

Please sign in to comment.