From b1365dccbb348578ee57fcf33a9f610f25a1da90 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 6 May 2026 13:52:44 +0200 Subject: [PATCH] feat(MoneyHistoryView): load branch names for enhanced activity display - Added a new method to load branch names from the API and map them by ID for better display in money history activities. - Updated the component's data structure to include a mapping of branch names, improving the clarity of tax-related activity translations. --- .../src/views/falukant/MoneyHistoryView.vue | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/falukant/MoneyHistoryView.vue b/frontend/src/views/falukant/MoneyHistoryView.vue index 8caa245..db6798e 100644 --- a/frontend/src/views/falukant/MoneyHistoryView.vue +++ b/frontend/src/views/falukant/MoneyHistoryView.vue @@ -72,6 +72,7 @@ export default { data() { return { filter: '', + branchNameById: {}, moneyHistory: { data: [], currentPage: 1, @@ -80,9 +81,27 @@ export default { }; }, async mounted() { + await this.loadBranchNames(); await this.fetchMoneyHistory(1); }, methods: { + async loadBranchNames() { + try { + const { data } = await apiClient.get('/api/falukant/branches'); + const map = {}; + for (const branch of Array.isArray(data) ? data : []) { + const id = Number(branch?.id); + if (!Number.isFinite(id)) continue; + const cityName = String(branch?.region?.name || '').trim(); + const branchType = String(branch?.branchType?.labelTr || '').trim(); + map[id] = cityName || branchType || `#${id}`; + } + this.branchNameById = map; + } catch (error) { + console.error('Error loading branch names for money history:', error); + this.branchNameById = {}; + } + }, async fetchMoneyHistory(page) { try { const response = await apiClient.post('/api/falukant/moneyhistory', { @@ -98,8 +117,10 @@ export default { if (typeof activity === 'string') { const taxMatch = activity.match(/^tax from sales branch\s+(\d+)$/i); if (taxMatch) { + const branchId = Number(taxMatch[1]); + const branchName = this.branchNameById[branchId] || `#${taxMatch[1]}`; return this.$t('falukant.moneyHistory.activities.taxFromSalesBranch', { - branchId: taxMatch[1], + branchId: branchName, }); }