Refine price comparison logic in getProductPricesInCities method of FalukantService

- Introduced a small tolerance (0.01) for rounding errors in the price comparison, allowing for more accurate evaluations when determining if a city's price exceeds the current price.
- This change enhances the robustness of price calculations by accommodating potential floating-point inaccuracies.
This commit is contained in:
Torsten Schulz (local)
2025-12-03 15:35:19 +01:00
parent 3f56939421
commit b3e48a0b06

View File

@@ -3750,8 +3750,9 @@ class FalukantService extends BaseService {
console.log(`[getProductPricesInCities] City: ${city.name} (${city.id}), worthPercent=${worthPercent}, basePrice=${basePrice}, priceInCity=${priceInCity}, currentPrice=${currentPrice}, isBetter=${priceInCity > currentPrice}`);
// Nur Städte zurückgeben, wo der Preis höher ist
// Keine Toleranz, da wir die aktuelle Stadt bereits ausschließen
if (priceInCity > currentPrice) {
// Kleine Toleranz (0.01) für Rundungsfehler bei Gleitkommaberechnungen
const PRICE_TOLERANCE = 0.01;
if (priceInCity > currentPrice - PRICE_TOLERANCE) {
// Branch-Typ bestimmen
let branchType = null; // null = kein Branch
if (city.branches && city.branches.length > 0) {