Fix
This commit is contained in:
@@ -3723,6 +3723,16 @@ class FalukantService extends BaseService {
|
|||||||
});
|
});
|
||||||
const worthMap = new Map(townWorths.map(tw => [tw.regionId, tw.worthPercent]));
|
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
|
// Für jede Stadt den Preis berechnen und Branch-Typ bestimmen
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const city of cities) {
|
for (const city of cities) {
|
||||||
@@ -3745,7 +3755,7 @@ class FalukantService extends BaseService {
|
|||||||
// Nur Städte zurückgeben, wo der Preis höher ist
|
// Nur Städte zurückgeben, wo der Preis höher ist
|
||||||
// Kleine Toleranz (0.01) für Rundungsfehler bei Gleitkommaberechnungen
|
// Kleine Toleranz (0.01) für Rundungsfehler bei Gleitkommaberechnungen
|
||||||
const PRICE_TOLERANCE = 0.01;
|
const PRICE_TOLERANCE = 0.01;
|
||||||
if (priceInCity > currentPrice - PRICE_TOLERANCE) {
|
if (priceInCity > currentRegionalPrice - PRICE_TOLERANCE) {
|
||||||
// Branch-Typ bestimmen
|
// Branch-Typ bestimmen
|
||||||
let branchType = null; // null = kein Branch
|
let branchType = null; // null = kein Branch
|
||||||
if (city.branches && city.branches.length > 0) {
|
if (city.branches && city.branches.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user