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, }); }