diff --git a/frontend/src/i18n/locales/de/falukant.json b/frontend/src/i18n/locales/de/falukant.json index 50b1f92..fb31654 100644 --- a/frontend/src/i18n/locales/de/falukant.json +++ b/frontend/src/i18n/locales/de/falukant.json @@ -583,6 +583,7 @@ "Production cost": "Produktionskosten", "Sell all products": "Alle Produkte verkauft", "sell products": "Produkte verkauft", + "taxFromSaleProduct": "Steuer aus Verkauf: {product}", "director starts production": "Direktor beginnt Produktion", "director payed out": "Direktorgehalt ausgezahlt", "Buy storage (type: field)": "Lagerplatz gekauft (Typ: Feld)", diff --git a/frontend/src/i18n/locales/en/falukant.json b/frontend/src/i18n/locales/en/falukant.json index 3bee28d..8e6869d 100644 --- a/frontend/src/i18n/locales/en/falukant.json +++ b/frontend/src/i18n/locales/en/falukant.json @@ -116,6 +116,7 @@ "Production cost": "Production cost", "Sell all products": "Sell all products", "sell products": "Sell products", + "taxFromSaleProduct": "Tax from product sale: {product}", "director starts production": "Director starts production", "director payed out": "Director salary paid out", "Buy storage (type: field)": "Bought storage (type: field)", diff --git a/frontend/src/views/falukant/MoneyHistoryView.vue b/frontend/src/views/falukant/MoneyHistoryView.vue index fda9101..6e167f5 100644 --- a/frontend/src/views/falukant/MoneyHistoryView.vue +++ b/frontend/src/views/falukant/MoneyHistoryView.vue @@ -67,12 +67,28 @@ export default { currentPage: 1, totalPages: 1, }, + productsById: {}, }; }, async mounted() { - await this.fetchMoneyHistory(1); + await Promise.all([this.loadProducts(), this.fetchMoneyHistory(1)]); }, methods: { + async loadProducts() { + try { + const { data } = await apiClient.get('/api/falukant/products'); + const map = {}; + for (const p of (data || [])) { + if (p && p.id != null && p.labelTr) { + map[String(p.id)] = p.labelTr; + } + } + this.productsById = map; + } catch (e) { + console.error('Error loading products for money history', e); + this.productsById = {}; + } + }, async fetchMoneyHistory(page) { try { const response = await apiClient.post('/api/falukant/moneyhistory', { @@ -85,6 +101,25 @@ export default { } }, translateActivity(activity) { + try { + const raw = String(activity ?? ''); + // Handle legacy format: "tax from sale product 3" + const m = raw.match(/^tax\s+from\s+sale\s+product\s+(\d+)$/i); + if (m && m[1]) { + const id = m[1]; + const labelTr = this.productsById[String(id)]; + const productName = labelTr ? this.$t(`falukant.product.${labelTr}`) : `#${id}`; + return this.$t('falukant.moneyHistory.activities.taxFromSaleProduct', { product: productName }); + } + // New/structured format: "taxFromSaleProduct." + if (raw.startsWith('taxFromSaleProduct.')) { + const labelTr = raw.substring('taxFromSaleProduct.'.length); + const productName = labelTr ? this.$t(`falukant.product.${labelTr}`) : labelTr; + return this.$t('falukant.moneyHistory.activities.taxFromSaleProduct', { product: productName }); + } + } catch (_) { + // ignore and fall back + } // Handle nested keys like "health.pill" -> "health.pill" const key = `falukant.moneyHistory.activities.${activity}`; const translation = this.$t(key);