From 641a2134cb2aa28cae4e009f5b0b022acd6ea7bc Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 9 Apr 2026 09:21:47 +0200 Subject: [PATCH] fix(falukant): improve product pricing logic and update localization for office notifications - Refactored the product pricing logic in `falukantService.js` to ensure accurate regional pricing calculations based on client values and server data. - Added new notification translations for "office filled" in multiple languages (Cebuano, German, English, Spanish, French) to enhance user experience and clarity in notifications. --- backend/services/falukantService.js | 12 +++++++----- frontend/src/i18n/locales/ceb/falukant.json | 1 + frontend/src/i18n/locales/de/falukant.json | 1 + frontend/src/i18n/locales/en/falukant.json | 1 + frontend/src/i18n/locales/es/falukant.json | 1 + frontend/src/i18n/locales/fr/falukant.json | 1 + 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 34fb510..9092b7c 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -7036,13 +7036,15 @@ ORDER BY r.id`, ? Number(clientPriceRaw) : NaN; let currentRegionalPrice; - if (!Number.isNaN(clientPriceNum)) { - // Referenzpreis wie in der Ertrags-Tabelle (z. B. MAX-Worth über Filialen) - currentRegionalPrice = clientPriceNum; - } else if (currentRegionId) { + // Wie getProductPricesInCities: bei bekannter Standort-Region immer + // serverseitigen Verkaufspreis dieser Region als Referenz — nicht den + // Client-Wert (Ertrags-Tabelle kann MAX-Worth über Filialen nutzen). + if (currentRegionId) { const wp = worthByProductRegion.get(`${product.id}-${currentRegionId}`) ?? 50; currentRegionalPrice = calcRegionalSellPriceSync(product, knowledgeFactor, wp) - ?? Number(product.sellCost) ?? 0; + ?? (!Number.isNaN(clientPriceNum) ? clientPriceNum : Number(product.sellCost) ?? 0); + } else if (!Number.isNaN(clientPriceNum)) { + currentRegionalPrice = clientPriceNum; } else { currentRegionalPrice = Number(product.sellCost) || 0; } diff --git a/frontend/src/i18n/locales/ceb/falukant.json b/frontend/src/i18n/locales/ceb/falukant.json index ded0a71..b496087 100644 --- a/frontend/src/i18n/locales/ceb/falukant.json +++ b/frontend/src/i18n/locales/ceb/falukant.json @@ -33,6 +33,7 @@ }, "notifications": { "notify_election_created": "Giskedyul ang usa ka bag-ong eleksiyon.", + "notify_office_filled": "Na puno ang usa ka politikal nga opisina.", "director_death": "Namatay si {characterName} sa edad nga {ageYears}. Isip amo, kinahanglan kang magtudlo og bag-ong direktor.{regionLabel}{spouses}{children}{lovers}", "relationship_death": "Namatay si {characterName} sa edad nga {ageYears}.{regionLabel}{spouses}{children}{lovers}", "child_death": "Namatay ang imong anak nga si {characterName} sa edad nga {ageYears}.{regionLabel}", diff --git a/frontend/src/i18n/locales/de/falukant.json b/frontend/src/i18n/locales/de/falukant.json index d9d3104..c96f5ff 100644 --- a/frontend/src/i18n/locales/de/falukant.json +++ b/frontend/src/i18n/locales/de/falukant.json @@ -47,6 +47,7 @@ }, "notifications": { "notify_election_created": "Es wurde eine neue Wahl ausgeschrieben.", + "notify_office_filled": "Ein politisches Amt wurde neu besetzt.", "director_death": "{characterName} ist im Alter von {ageYears} Jahren verstorben. Als Arbeitgeber musst du die Direktion neu besetzen.{regionLabel}{spouses}{children}{lovers}", "relationship_death": "{characterName} ist im Alter von {ageYears} Jahren verstorben.{regionLabel}{spouses}{children}{lovers}", "child_death": "Dein Kind {characterName} ist im Alter von {ageYears} Jahren verstorben.{regionLabel}", diff --git a/frontend/src/i18n/locales/en/falukant.json b/frontend/src/i18n/locales/en/falukant.json index 3128235..2118304 100644 --- a/frontend/src/i18n/locales/en/falukant.json +++ b/frontend/src/i18n/locales/en/falukant.json @@ -33,6 +33,7 @@ }, "notifications": { "notify_election_created": "A new election has been scheduled.", + "notify_office_filled": "A political office has been filled.", "director_death": "{characterName} died at the age of {ageYears}. As employer you need to appoint a new director.{regionLabel}{spouses}{children}{lovers}", "relationship_death": "{characterName} died at the age of {ageYears}.{regionLabel}{spouses}{children}{lovers}", "child_death": "Your child {characterName} died at the age of {ageYears}.{regionLabel}", diff --git a/frontend/src/i18n/locales/es/falukant.json b/frontend/src/i18n/locales/es/falukant.json index 11ea422..817aa88 100644 --- a/frontend/src/i18n/locales/es/falukant.json +++ b/frontend/src/i18n/locales/es/falukant.json @@ -47,6 +47,7 @@ }, "notifications": { "notify_election_created": "Se ha convocado una nueva elección.", + "notify_office_filled": "Se ha cubierto un cargo político.", "director_death": "{characterName} ha fallecido a la edad de {ageYears} años. Como empleador debes nombrar un nuevo director.{regionLabel}{spouses}{children}{lovers}", "relationship_death": "{characterName} ha fallecido a la edad de {ageYears} años.{regionLabel}{spouses}{children}{lovers}", "child_death": "Tu hijo/a {characterName} ha fallecido a la edad de {ageYears} años.{regionLabel}", diff --git a/frontend/src/i18n/locales/fr/falukant.json b/frontend/src/i18n/locales/fr/falukant.json index 2697547..5f230ec 100644 --- a/frontend/src/i18n/locales/fr/falukant.json +++ b/frontend/src/i18n/locales/fr/falukant.json @@ -47,6 +47,7 @@ }, "notifications": { "notify_election_created": "Une nouvelle élection a été déclenchée.", + "notify_office_filled": "Une fonction politique a été pourvue.", "director_death": "{characterName} est décédé à l'âge de {ageYears}. En tant qu'employeur, vous devez remplir le conseil d'administration.{regionLabel}{spouses}{children}{lovers}", "relationship_death": "{characterName} est décédé à l'âge de {ageYears}.{regionLabel}{spouses}{children}{lovers}", "child_death": "Votre enfant {characterName} est décédé à l'âge de {ageYears}.{regionLabel}",