This commit is contained in:
Torsten Schulz (local)
2025-12-03 16:29:56 +01:00
parent 3c885b6ab9
commit a51b8a1ff6

View File

@@ -3723,6 +3723,16 @@ class FalukantService extends BaseService {
});
const worthMap = new Map(townWorths.map(tw => [tw.regionId, tw.worthPercent]));
// Berechne den regionalen Preis für die aktuelle Region (falls angegeben)
let currentRegionalPrice = currentPrice; // Fallback auf übergebenen Preis
if (currentRegionId) {
const currentWorthPercent = worthMap.get(currentRegionId) || 50;
const currentBasePrice = product.sellCost * (currentWorthPercent / 100);
const currentMin = currentBasePrice * 0.6;
const currentMax = currentBasePrice;
currentRegionalPrice = currentMin + (currentMax - currentMin) * (knowledgeFactor / 100);
}
// Für jede Stadt den Preis berechnen und Branch-Typ bestimmen
const results = [];
for (const city of cities) {
@@ -3745,7 +3755,7 @@ class FalukantService extends BaseService {
// Nur Städte zurückgeben, wo der Preis höher ist
// Kleine Toleranz (0.01) für Rundungsfehler bei Gleitkommaberechnungen
const PRICE_TOLERANCE = 0.01;
if (priceInCity > currentPrice - PRICE_TOLERANCE) {
if (priceInCity > currentRegionalPrice - PRICE_TOLERANCE) {
// Branch-Typ bestimmen
let branchType = null; // null = kein Branch
if (city.branches && city.branches.length > 0) {