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:
@@ -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);
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
:products="products"
|
||||
:calculateProductRevenue="calculateProductRevenue"
|
||||
:calculateProductProfit="calculateProductProfit"
|
||||
:currentRegionId="selectedBranch?.regionId"
|
||||
ref="revenueSection"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user