Enhance product price retrieval by including currentRegionId in FalukantController and FalukantService

- Updated the FalukantController to accept currentRegionId as a parameter for fetching product prices in cities.
- Modified the FalukantService to incorporate currentRegionId in the price calculation logic, allowing exclusion of the current region from results.
- Adjusted frontend components to pass currentRegionId, improving the accuracy of price comparisons and user experience.
This commit is contained in:
Torsten Schulz (local)
2025-12-03 08:39:30 +01:00
parent 6ec62af606
commit 4eeb5021ee
4 changed files with 14 additions and 11 deletions

View File

@@ -53,6 +53,7 @@
products: { type: Array, required: true },
calculateProductRevenue: { type: Function, required: true },
calculateProductProfit: { type: Function, required: true },
currentRegionId: { type: Number, default: null },
},
data() {
return {
@@ -103,14 +104,13 @@
this.loadingPrices.add(product.id);
try {
const currentPrice = parseFloat(this.calculateProductRevenue(product).absolute);
console.log(`[RevenueSection] Loading prices for product ${product.id} (${product.labelTr}), currentPrice: ${currentPrice}`);
const { data } = await apiClient.get('/api/falukant/products/prices-in-cities', {
params: {
productId: product.id,
currentPrice: currentPrice
currentPrice: currentPrice,
currentRegionId: this.currentRegionId
}
});
console.log(`[RevenueSection] Received better prices for product ${product.id}:`, data);
this.$set(product, 'betterPrices', data || []);
} catch (error) {
console.error(`Error loading prices for product ${product.id}:`, error);