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:
@@ -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}`);
|
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
|
// Nur Städte zurückgeben, wo der Preis höher ist
|
||||||
// Keine Toleranz, da wir die aktuelle Stadt bereits ausschließen
|
// Kleine Toleranz (0.01) für Rundungsfehler bei Gleitkommaberechnungen
|
||||||
if (priceInCity > currentPrice) {
|
const PRICE_TOLERANCE = 0.01;
|
||||||
|
if (priceInCity > currentPrice - 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